evm

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2022 License: Apache-2.0, BSD-2-Clause Imports: 3 Imported by: 1

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.

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

  1. Start a test cluster:

    wasp-cluster start -d
    
  2. In a different terminal, initialize a private key and request some iotas from the faucet:

    wasp-cli init
    wasp-cli request-funds
    
  3. 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
    
  4. Send some iotas from your L1 account to any Ethereum account on L2 (e.g. to cover for gas fees):

    wasp-cli chain deposit 0xa1b2c3d4... iota:1000000
    
  5. Visit the Wasp dashboard at http://localhost:7000, go to Chains, 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

Index

Constants

View Source
const (
	FieldTransaction      = evmnames.FieldTransaction
	FieldCallMsg          = evmnames.FieldCallMsg
	FieldChainID          = evmnames.FieldChainID
	FieldGenesisAlloc     = evmnames.FieldGenesisAlloc
	FieldAddress          = evmnames.FieldAddress
	FieldKey              = evmnames.FieldKey
	FieldAgentID          = evmnames.FieldAgentID
	FieldTransactionIndex = evmnames.FieldTransactionIndex
	FieldTransactionHash  = evmnames.FieldTransactionHash
	FieldResult           = evmnames.FieldResult
	FieldBlockNumber      = evmnames.FieldBlockNumber
	FieldBlockHash        = evmnames.FieldBlockHash
	FieldGasRatio         = evmnames.FieldGasRatio
	FieldBlockGasLimit    = evmnames.FieldBlockGasLimit
	FieldFilterQuery      = evmnames.FieldFilterQuery
	FieldBlockKeepAmount  = evmnames.FieldBlockKeepAmount
)
View Source
const (
	// TODO shouldn't this be different between chain, to prevent replay attacks? (maybe derived from ISC ChainID)
	DefaultChainID = uint16(1074) // IOTA -- get it?

	BlockGasLimitDefault = uint64(15000000)

	BlockKeepAll           = -1
	BlockKeepAmountDefault = BlockKeepAll
)

Variables

View Source
var (
	// EVM state
	FuncSendTransaction                     = coreutil.Func(evmnames.FuncSendTransaction)
	FuncEstimateGas                         = coreutil.Func(evmnames.FuncEstimateGas)
	FuncGetBalance                          = coreutil.ViewFunc(evmnames.FuncGetBalance)
	FuncCallContract                        = coreutil.ViewFunc(evmnames.FuncCallContract)
	FuncGetNonce                            = coreutil.ViewFunc(evmnames.FuncGetNonce)
	FuncGetReceipt                          = coreutil.ViewFunc(evmnames.FuncGetReceipt)
	FuncGetCode                             = coreutil.ViewFunc(evmnames.FuncGetCode)
	FuncGetBlockNumber                      = coreutil.ViewFunc(evmnames.FuncGetBlockNumber)
	FuncGetBlockByNumber                    = coreutil.ViewFunc(evmnames.FuncGetBlockByNumber)
	FuncGetBlockByHash                      = coreutil.ViewFunc(evmnames.FuncGetBlockByHash)
	FuncGetTransactionByHash                = coreutil.ViewFunc(evmnames.FuncGetTransactionByHash)
	FuncGetTransactionByBlockHashAndIndex   = coreutil.ViewFunc(evmnames.FuncGetTransactionByBlockHashAndIndex)
	FuncGetTransactionByBlockNumberAndIndex = coreutil.ViewFunc(evmnames.FuncGetTransactionByBlockNumberAndIndex)
	FuncGetTransactionCountByBlockHash      = coreutil.ViewFunc(evmnames.FuncGetTransactionCountByBlockHash)
	FuncGetTransactionCountByBlockNumber    = coreutil.ViewFunc(evmnames.FuncGetTransactionCountByBlockNumber)
	FuncGetStorage                          = coreutil.ViewFunc(evmnames.FuncGetStorage)
	FuncGetLogs                             = coreutil.ViewFunc(evmnames.FuncGetLogs)
	FuncGetChainID                          = coreutil.ViewFunc(evmnames.FuncGetChainID)

	// evm SC management
	FuncSetGasRatio = coreutil.Func(evmnames.FuncSetGasRatio)
	FuncGetGasRatio = coreutil.ViewFunc(evmnames.FuncGetGasRatio)

	// block context
	FuncOpenBlockContext  = coreutil.Func(evmnames.FuncOpenBlockContext)
	FuncCloseBlockContext = coreutil.Func(evmnames.FuncCloseBlockContext)
)
View Source
var Contract = coreutil.NewContract(evmnames.Contract, "EVM contract")
View Source
var GasPrice = big.NewInt(0)

Gas is charged in isc VM (L1 currencies), not ETH

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
package evmnames provides the names of EVM core contract functions and fields.
package evmnames provides the names of EVM core contract functions and fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL