Magic Contract
- Common type definitions
- ISC library
- ISCSandbox
interface, available at
ISC.sandbox
- ISCAccounts
interface, available at
ISC.accounts
- ISCUtil
interface, available at
ISC.util
- ERC20BaseTokens
contract, available at
ISC.baseTokens
(address0x1074010000000000000000000000000000000000
) - ERC20NativeTokens
contract, available at
ISC.nativeTokens(foundrySN)
after being registered by the foundry owner by callingregisterERC20NativeToken
(address0x107402xxxxxxxx00000000000000000000000000
wherexxxxxxxx
is the little-endian encoding of the foundry serial number) - ERC20ExternalNativeTokens
contract, available at a dynamically assigned address after being registered
by the foundry owner by calling
registerERC20NativeTokenOnRemoteChain
on the chain that controls the foundry. - ERC721NFTs
contract, available at
ISC.nfts
(address0x1074030000000000000000000000000000000000
) - ERC721NFTCollection
contract, available at
ISC.erc721NFTCollection(collectionID)
, after being registered by callingregisterERC721NFTCollection
.
There are some usage examples in the ISC How-To Guides and the ISCTest.sol contract (used internally in unit tests).
Call a Native Contract
You can call native contracts using ISC.sandbox.call
:
pragma solidity >=0.8.5;
import "@iota/iscmagic/ISC.sol";
contract MyEVMContract {
event EntropyEvent(bytes32 entropy);
function callInccounter() public {
ISCDict memory params = ISCDict(new ISCDictItem[](1));
bytes memory int64Encoded42 = hex"2A00000000000000";
params.items[0] = ISCDictItem("counter", int64Encoded42);
ISCAssets memory allowance;
ISC.sandbox.call(ISC.util.hn("inccounter"), ISC.util.hn("incCounter"), params, allowance);
}
}
ISC.util.hn
is used to get the hname
of the inccounter
contract and the
incCounter
entry point. You can also call view entry points using
ISC.sandbox.callView.