README ¶
EVM support
This package and subpackages contain the code for the evm
core contract, which allows to execute Ethereum VM (EVM) code on top of the
ISC chain, thus adding support for Ethereum smart contracts.
Installing @iscmagic contracts
The @iscmagic contracts are installable via NPM with
npm install --save @iota/iscmagic
After installing @iota/iscmagic
you can use the functions by importing them as you normally would.
import "@iota/iscmagic/ISC.sol"
...
...
JSON-RPC
The Wasp node provides a JSON-RPC service at /chain/<isc-chainid>/evm/jsonrpc
. This will
allow you to connect any standard Ethereum tool, like Metamask. You can check
the Metamask connection parameters for any given ISC chain in the Dashboard.
Complete example using wasp-cluster
-
Start a test cluster:
wasp-cluster start -d
-
In a different terminal, initialize a private key and request some iotas from the faucet:
wasp-cli init wasp-cli request-funds
-
Deploy an ISC chain with an arbitrary Ethereum chain ID (which should be different from any standard Ethereum chain IDs -- see https://chainlist.org):
wasp-cli chain deploy --chain=mychain --evm-chainid 1234
-
Send some base tokens from your L1 account to any Ethereum account on L2 (e.g. to cover for gas fees):
wasp-cli chain deposit 0xa1b2c3d4... base:1000000
-
Visit the Wasp dashboard (
<URL>/wasp/dashboard
when usingnode-docker-setup
), go toChains
, then to your ISC chain, scroll down and you will find the EVM section with the JSON-RPC URL for Metamask or any other Ethereum tool.
You can now deploy an EVM contract like you would on Ethereum.
For more information check out the docs.
Documentation ¶
Overview ¶
Package evm contains the declaration of the evm core contract's interface.
Index ¶
- Constants
- Variables
- func ContractPartition(chainState kv.KVStore) kv.KVStore
- func ContractPartitionR(chainState kv.KVStoreReader) kv.KVStoreReader
- func EmulatorStateSubrealm(evmPartition kv.KVStore) kv.KVStore
- func EmulatorStateSubrealmR(evmPartition kv.KVStoreReader) kv.KVStoreReader
- func EncodePackedNFTURI(metadata *isc.IRC27NFTMetadata) string
- func ISCMagicSubrealm(evmPartition kv.KVStore) kv.KVStore
- func ISCMagicSubrealmR(evmPartition kv.KVStoreReader) kv.KVStoreReader
- type PackedNFTURI
Constants ¶
const ( FieldTransaction = evmnames.FieldTransaction FieldCallMsg = evmnames.FieldCallMsg FieldChainID = evmnames.FieldChainID FieldAddress = evmnames.FieldAddress FieldAssets = evmnames.FieldAssets FieldKey = evmnames.FieldKey FieldAgentID = evmnames.FieldAgentID FieldTransactionIndex = evmnames.FieldTransactionIndex FieldTransactionHash = evmnames.FieldTransactionHash FieldResult = evmnames.FieldResult FieldBlockNumber = evmnames.FieldBlockNumber FieldBlockHash = evmnames.FieldBlockHash FieldFilterQuery = evmnames.FieldFilterQuery FieldBlockKeepAmount = evmnames.FieldBlockKeepAmount // int32 FieldNativeTokenID = evmnames.FieldNativeTokenID FieldFoundrySN = evmnames.FieldFoundrySN // uint32 FieldTokenName = evmnames.FieldTokenName // string FieldTokenTickerSymbol = evmnames.FieldTokenTickerSymbol // string FieldTokenDecimals = evmnames.FieldTokenDecimals // uint8 FieldNFTCollectionID = evmnames.FieldNFTCollectionID // NFTID FieldFoundryTokenScheme = evmnames.FieldFoundryTokenScheme FieldTargetAddress = evmnames.FieldTargetAddress FieldAgentIDDepositOriginator = evmnames.FieldAgentIDDepositOriginator FieldAgentIDWithdrawalTarget = evmnames.FieldAgentIDWithdrawalTarget FieldFromAddress = evmnames.FieldFromAddress FieldToAddress = evmnames.FieldToAddress )
const ( // TODO shouldn't this be different between chain, to prevent replay attacks? (maybe derived from ISC ChainID) DefaultChainID = uint16(1074) // IOTA -- get it? )
Variables ¶
var ( // FuncSendTransaction is the main entry point, called by an // evmOffLedgerTxRequest in order to process an Ethereum tx (e.g. // eth_sendRawTransaction). FuncSendTransaction = coreutil.Func(evmnames.FuncSendTransaction) // FuncCallContract is the entry point called by an evmOffLedgerCallRequest // in order to process a view call or gas estimation (e.g. eth_call, eth_estimateGas). FuncCallContract = coreutil.Func(evmnames.FuncCallContract) FuncGetChainID = coreutil.ViewFunc(evmnames.FuncGetChainID) FuncRegisterERC20NativeToken = coreutil.Func(evmnames.FuncRegisterERC20NativeToken) FuncRegisterERC20NativeTokenOnRemoteChain = coreutil.Func(evmnames.FuncRegisterERC20NativeTokenOnRemoteChain) FuncRegisterERC20ExternalNativeToken = coreutil.Func(evmnames.FuncRegisterERC20ExternalNativeToken) FuncGetERC20ExternalNativeTokenAddress = coreutil.ViewFunc(evmnames.FuncGetERC20ExternalNativeTokenAddress) FuncGetERC721CollectionAddress = coreutil.ViewFunc(evmnames.FuncGetERC721CollectionAddress) FuncRegisterERC721NFTCollection = coreutil.Func(evmnames.FuncRegisterERC721NFTCollection) FuncNewL1Deposit = coreutil.Func(evmnames.FuncNewL1Deposit) )
var Contract = coreutil.NewContract(evmnames.Contract)
Functions ¶
func ContractPartitionR ¶ added in v1.0.3
func ContractPartitionR(chainState kv.KVStoreReader) kv.KVStoreReader
func EmulatorStateSubrealm ¶ added in v1.0.3
func EmulatorStateSubrealmR ¶ added in v1.0.3
func EmulatorStateSubrealmR(evmPartition kv.KVStoreReader) kv.KVStoreReader
func EncodePackedNFTURI ¶ added in v1.3.0
func EncodePackedNFTURI(metadata *isc.IRC27NFTMetadata) string
func ISCMagicSubrealmR ¶ added in v1.0.3
func ISCMagicSubrealmR(evmPartition kv.KVStoreReader) kv.KVStoreReader
Types ¶
type PackedNFTURI ¶ added in v1.3.0
type PackedNFTURI struct { Name string `json:"name"` Description string `json:"description,omitempty"` Attributes []interface{} `json:"attributes,omitempty"` Image string `json:"image"` }
This hack is so that the ERC721 tokenURI view function returns the NFT name and description for explorers
func DecodePackedNFTURI ¶ added in v1.3.0
func DecodePackedNFTURI(uri string) (*PackedNFTURI, error)
Directories ¶
Path | Synopsis |
---|---|
Package emulator contains the implementation of the EVMEmulator and subcomponents.
|
Package emulator contains the implementation of the EVMEmulator and subcomponents. |
Package evmimpl contains the implementation of the `evm` core contract.
|
Package evmimpl contains the implementation of the `evm` core contract. |
package evmnames provides the names of EVM core contract functions and fields.
|
package evmnames provides the names of EVM core contract functions and fields. |
Package evmtest contains solo tests for the evm core contract.
|
Package evmtest contains solo tests for the evm core contract. |