Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISC Restructure - Small Fixes #1498

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ EIP))
, [NFTs](/learn/protocols/stardust/core-concepts/multi-asset-ledger#non-fungible-tokens-nfts), [Smart Contracts](/learn/smart-contracts/introduction)
and have already tinkered with [Solidity](https://docs.soliditylang.org/en/v0.8.16/).

You should also have basic knowledge on how to [create](../how-tos/EVM/create-a-basic-contract.md) and [deploy](../how-tos/EVM/deploy-a-smart-contract.mdx)
You should also have basic knowledge on how to [create](../how-tos/create-a-basic-contract.md) and [deploy](../how-tos/deploy-a-smart-contract.mdx)
a smart contract.

:::
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:::warning EVM Compatibility
:::info EVM Compatibility

The ISC EVM layer is also designed to be as compatible as possible with existing Ethereum
[tools](../getting-started/tools.mdx) and functionalities. However, please make sure you have checked out the current
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:::tip Deploy a Smart Contract

Deploy a Solidity Smart Contract following our [how to Deploy a Smart Contract guide](/isc/how-tos/deploy-a-smart-contract#remix).

:::

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
1. Check if the amount paid to the contract is the same as the required [storage deposit](/learn/protocols/stardust/core-concepts/storage-deposit)
### 1. Check the Storage Deposit

Check if the amount paid to the contract is the same as the required [storage deposit](/learn/protocols/stardust/core-concepts/storage-deposit)
and set the allowance.

```solidity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ The [`accounts` core contract](../reference/core-contracts/accounts.md) is respo
By calling this contract, it is possible to:

- [View current account balances](../how-tos/get-balance.md)
- [Deposit funds to the chain](../how-tos/EVM/send-funds-from-L1-to-L2.mdx)
- [Deposit funds to the chain](../how-tos/send-funds-from-L1-to-L2.mdx)
- [Withdraw funds from the chain](../how-tos/send-assets-to-l1.mdx)

## Example

The following diagram illustrates an example situation.
The the IDs and hnames are shortened for simplicity.
The IDs and hnames are shortened for simplicity.

[![Example situation. Two chains are deployed, with three smart contracts and one address.](/img/tutorial/accounts.png)](/img/tutorial/accounts.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Here are some of the most important properties and limitations of EVM support in

### Wrapped Calls to the JSON-RPC

The Wasp node provides a JSON-RPC service, the standard protocol used by Ethereum tools. Upon receiving a signed
The Wasp node provides a JSON-RPC service, the standard protocol used by Ethereum tools. We try to keep our endpoint as compatible as possible, you can find a list of supported endpoints [here](../reference/json-rpc-spec.md). Upon receiving a signed
Ethereum transaction via JSON-RPC, the transaction is wrapped into an ISC
[off-ledger request](../explanations/invocation.md#off-ledger-requests). The sender of the request
is the Ethereum address that signed the original transaction (e.g., the Metamask account).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Please read [the MetaMask section in the tools guide](tools.mdx#metamask) for a

:::tip ShimmerEVM

If you want to fund your ShimmerEVM account, please refer to our [How To Get Funds guide](../how-tos/EVM/send-funds-from-L1-to-L2.mdx).
If you want to fund your ShimmerEVM account, please refer to our [How To Get Funds guide](../how-tos/send-funds-from-L1-to-L2.mdx).

:::

Expand Down
7 changes: 3 additions & 4 deletions docs/build/isc/v1.0.0-rc.6/docs/getting-started/tools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ tags:
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import {AddToMetaMaskButton, EVMNetworks} from '@theme/AddToMetaMaskButton';
import DeployWithRemix from '../_admonitions/_deploy_with_remix.md';
import DeployWithHardhat from '../_admonitions/_deploy_with_hardhat.md';
import DeployAdmonition from '../_admonitions/_deploy_a_smart_contract.md';
import { ChainId } from '@theme/ChainId';

# Compatible Tools
Expand Down Expand Up @@ -97,7 +96,7 @@ the `Environment` dropdown.

![Select Injected Provider from the Environment dropdown](/img/evm/remix-injected-provider-metamask.png)

<DeployWithRemix/>
<DeployAdmonition/>

Metamask will ask to connect to Remix, and once connected, it will set the `Environment` to `Injected Web3` with
the "Custom (<ChainId url='https://json-rpc.evm.shimmer.network'/>) network" or "Custom (<ChainId url='https://json-rpc.evm.testnet.shimmer.network'/>) network".
Expand Down Expand Up @@ -144,7 +143,7 @@ networks: {
</TabItem>
</Tabs>

<DeployWithHardhat/>
<DeployAdmonition/>

:::caution

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ tags:
- how to
---

import DeployWithRemix from '../../_admonitions/_deploy_with_remix.md';
import PriorKnowledge from '../../_admonitions/_EVM-required-prior-knowledge.md';
import RemixIDE from '../../_admonitions/_remix-IDE.md';
import DeployAdmonition from '../_admonitions/_deploy_a_smart_contract.md';
import PriorKnowledge from '../_admonitions/_EVM-required-prior-knowledge.md';
import RemixIDE from '../_admonitions/_remix-IDE.md';

# Create ERC20 Custom Tokens

Expand Down Expand Up @@ -66,7 +66,7 @@ You can change the token name `ExampleERC20Token` and the token symbol `EET` for

:::

<DeployWithRemix/>
<DeployAdmonition/>

## 2. Add Your Custom Tokens to MetaMask

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ tags:
- mint tokens
- how to
---
import DeployWithRemix from '../../_admonitions/_deploy_with_remix.md';
import PriorKnowledge from '../../_admonitions/_EVM-required-prior-knowledge.md';
import RemixIDE from '../../_admonitions/_remix-IDE.md';
import DeployAdmonition from '../_admonitions/_deploy_a_smart_contract.md';
import PriorKnowledge from '../_admonitions/_EVM-required-prior-knowledge.md';
import RemixIDE from '../_admonitions/_remix-IDE.md';

# Create ERC721 NFTs

Expand Down Expand Up @@ -44,7 +44,7 @@ your smart contracts.

The following is an example NFT Smart Contract called "ShimmerEVMSampleNFT".

```solidity {2,11,16,19-22}
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

Expand Down Expand Up @@ -107,7 +107,7 @@ Before you can deploy this contract, you will need to set the `Initial Owner` ad

:::

<DeployWithRemix/>
<DeployAdmonition/>

### Mint Your Custom NFTs

Expand Down
12 changes: 9 additions & 3 deletions docs/build/isc/v1.0.0-rc.6/docs/how-tos/allowance/allow.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ In ISC, we have a similar concept for our native assets. You might want to use t

## Example Code

1. Create a function which allows an address or contract to access a specific ID of your account:
### 1. Create the `allow` Function

Create a function which allows an address or contract to access a specific ID of your account:

```solidity
function allow(address _address, bytes32 _allowanceNFTID) public {
```

2. Create an `ISCAssets` object to pass as allowance:
### 2. Create the `ISCAssets` object

Create an `ISCAssets` object to pass as allowance:

```solidity
NFTID[] memory nftIDs = new NFTID[](1);
Expand All @@ -31,7 +35,9 @@ ISCAssets memory assets;
assets.nfts = nftIDs;
```

3. With that asset, you can call `allow` to allow address to take our NFT:
### 3. Use the Assets as Allowance

With that asset, you can call `allow` to allow address to take our NFT:

```solidity
ISC.sandbox.allow(_address, assets);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ After having [allowed](./allow.md) native assets, you can take the ones you need

The following example will take the NFT which was allowed in the [allow how-to guide](./allow.md).

### Create the `ISCAssets`

First, you need to recreate the `ISCAssets` with the NFTID.

```solidity
Expand All @@ -25,6 +27,8 @@ ISCAssets memory assets;
assets.nfts = nftIDs;
```

### Call `takeAllowedFunds()`

After that, you can call `takeAllowedFunds()` to take the allowance of the specified address/contract

```solidity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tags:
- how to
- basic contract
---
import DeployAdmonition from '../_admonitions/_deploy_a_smart_contract.md';

# Solidity Smart Contract Example

Expand Down Expand Up @@ -43,10 +44,12 @@ contract Counter {
```

This contract simply updates a `count` variable. It has
three [entry points](../../explanations/smart-contract-anatomy.md#entry-points):
three [entry points](../explanations/smart-contract-anatomy.md#entry-points):

* `increment` and `decrement`: Two full entry points that can alter
the [state](../../explanations/smart-contract-anatomy.md#state), i.e. the `count variable`.
the [state](../explanations/smart-contract-anatomy.md#state), i.e. the `count variable`.
* `getCount`: A view only entry point, which simply renders the current `count` state.

For more information, please visit the [official Solidity documentation](https://docs.soliditylang.org/).

<DeployAdmonition />
7 changes: 7 additions & 0 deletions docs/build/isc/v1.0.0-rc.6/docs/how-tos/get-balance.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ tags:

Once you have your L1 assets on L2, you might want to check their balance. This guide explains how to do so by calling the three functions `getL2BalanceBaseTokens`, `getL2BalanceNativeTokens`and `getL2NFTAmount` for the corresponding token types.


## Example Code

1. Get the [AgentID](../explanations/how-accounts-work.md) from the sender by calling `ISC.sandbox.getSenderAccount()`.
Expand All @@ -21,15 +22,20 @@ ISCAgentID memory agentID = ISC.sandbox.getSenderAccount();
```

2. To get the base token balance, you can call `getL2BalanceBaseTokens` using the `agentID`.

```solidity
uint64 baseBalance = ISC.accounts.getL2BalanceBaseTokens(agentID);
```

3. To get the native token balance of a specific `NativeTokenID`, use `ISC.accounts.getL2BalanceNativeTokens` with the `id` and `agentID`.

```solidity
NativeTokenID memory id = NativeTokenID({ data: nativeTokenID});
uint256 nativeTokens = ISC.accounts.getL2BalanceNativeTokens(id, agentID);
```

4. To get the number of NFTs, use `ISC.accounts.getL2NFTAmount` with the `agentID`.

```solidity
uint256 nfts = ISC.accounts.getL2NFTAmount(agentID);
```
Expand Down Expand Up @@ -65,3 +71,4 @@ contract GetBalance {
}
}
```

100 changes: 50 additions & 50 deletions docs/build/isc/v1.0.0-rc.6/docs/how-tos/get-randomness-on-l2.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,56 +26,6 @@ While entropy is random for each smart contract request, entropy is constant wit

:::

## Example

```solidity
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@iota/iscmagic/ISC.sol";

contract Random {
event Int(uint256);
event Bytes(bytes);

uint256 private _nonce;

function getNonce() internal returns (bytes32) {
return bytes32(_nonce++);
}

function getInt() public returns (uint256) {
bytes32 entropy = ISC.sandbox.getEntropy();
bytes32 nonce = getNonce();
bytes32 digest = keccak256(bytes.concat(entropy, nonce));

uint256 value = uint256(digest);

emit Int(value);
return value;
}

function getBytes(uint length) public returns (bytes memory) {
bytes32 entropy = ISC.sandbox.getEntropy();
bytes32 nonce = getNonce();
bytes32 digest = keccak256(bytes.concat(entropy, nonce));

bytes memory value = new bytes(length);
for (uint i = 0; i < length; i += 32) {
digest = keccak256(bytes.concat(digest));
for (uint j = 0; j < 32 && i + j < length; j++) {
value[i + j] = digest[j];
}
}

emit Bytes(value);
return value;
}
}

```

## Explanation

When you want to generate multiple random values within a single request, you need to take into account that entropy is constant within a request. In this contract we use an increasing nonce in addition to the entropy, to make sure we are generating unique values:
Expand Down Expand Up @@ -125,3 +75,53 @@ for (uint i = 0; i < length; i += 32) {
}
}
```

## Full Example Code

```solidity
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@iota/iscmagic/ISC.sol";

contract Random {
event Int(uint256);
event Bytes(bytes);

uint256 private _nonce;

function getNonce() internal returns (bytes32) {
return bytes32(_nonce++);
}

function getInt() public returns (uint256) {
bytes32 entropy = ISC.sandbox.getEntropy();
bytes32 nonce = getNonce();
bytes32 digest = keccak256(bytes.concat(entropy, nonce));

uint256 value = uint256(digest);

emit Int(value);
return value;
}

function getBytes(uint length) public returns (bytes memory) {
bytes32 entropy = ISC.sandbox.getEntropy();
bytes32 nonce = getNonce();
bytes32 digest = keccak256(bytes.concat(entropy, nonce));

bytes memory value = new bytes(length);
for (uint i = 0; i < length; i += 32) {
digest = keccak256(bytes.concat(digest));
for (uint j = 0; j < 32 && i + j < length; j++) {
value[i + j] = digest[j];
}
}

emit Bytes(value);
return value;
}
}

```
2 changes: 1 addition & 1 deletion docs/build/isc/v1.0.0-rc.6/docs/how-tos/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ beginner or an experienced developer, the how-to guides offer clear and concise
functionality into your projects easier.

To make the most of the how-to guides in this section, identify the specific topic or functionality you want to explore.
Whether you want to [get funds on L2](EVM/send-funds-from-L1-to-L2.mdx), [add ISC specific functionality](magic.md),
Whether you want to [get funds on L2](send-funds-from-L1-to-L2.mdx), [add ISC specific functionality](magic.md),
or [send funds to L1](send-assets-to-l1.mdx), you can find dedicated guides that walk you through the process.

With the how-to guides in the IOTA SDK, you can overcome implementation hurdles and gain a deeper understanding
Expand Down
Loading