Skip to main content
Version: v1.4

The Core Contracts

The core contracs are contracts deployed on every chain and are vital to interact with L1 and the chain itself. They can be called in Solidity through the ISC Magic Contract.

The ISC Magic Contract

The Magic contract is an EVM contract deployed by default on every ISC chain, in the EVM genesis block, at address 0x1074000000000000000000000000000000000000. The implementation of the Magic contract is baked-in in the evm core contract; i.e. it is not a pure-Solidity contract.

The Magic contract has several methods, which are categorized into specialized interfaces: ISCSandbox, ISCAccounts, ISCUtil and so on. You can access these interfaces from any Solidity contract by importing the ISC library:

npm install @iota/iscmagic

You can import it into your contracts like this:

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

The Magic contract also provides proxy ERC20 contracts to manipulate ISC base tokens and native tokens on L2.

Reference Docs

If you need further info about magic contracts interfaces you can check out the magic contract docs.

Call a Function

Ease of use

To make it easier for developers to use the core contracts, you should, in most cases, run the functions from the magic contract directly. For example, to get the native token balance, you could call the balanceNativeToken() directly with callView, or use getl2balancenativetokens of the magic contract, or (the suggested way) register your native token as ERC20 and call the standard balanceof function. What you use also depends on what you optimize for. For example, to save gas, it could be interesting for you to call core contracts from your favorite web3 library directly and compute other things off-chain.

In the example below, ISC.sandbox.getEntropy() calls the getEntropy method of the ISCSandbox interface, which, in turn, calls ISC Sandbox's GetEntropy.

pragma solidity >=0.8.5;

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

contract MyEVMContract {
event EntropyEvent(bytes32 entropy);

// this will emit a "random" value taken from the ISC entropy value
function emitEntropy() public {
bytes32 e = ISC.sandbox.getEntropy();
emit EntropyEvent(e);
}
}