Documentation ¶
Index ¶
- func CanTransfer(db types.StateDB, addr, token common.Address, amount *big.Int) bool
- func GetHashFn(ref *types.Header, chain ChainContext) func(n uint64) common.Hash
- func IsWasmContract(code []byte) bool
- func Transfer(db types.StateDB, sender, recipient, token common.Address, amount *big.Int)
- func UnsafeTransfer(db types.StateDB, recipient, token common.Address, amount *big.Int)
- type AccountRef
- type CanTransferFunc
- type ChainContext
- type Config
- type Context
- type Contract
- func (c *Contract) Address() common.Address
- func (c *Contract) AsDelegate() *Contract
- func (c *Contract) Caller() common.Address
- func (c *Contract) SetCallCode(addr *common.Address, hash common.Hash, code []byte)
- func (c *Contract) SetCode(hash common.Hash, code []byte)
- func (c *Contract) UseGas(gas uint64) (ok bool)
- func (c *Contract) Value() *big.Int
- type ContractRef
- type GetHashFunc
- type TCBlockHash
- type TCCallContract
- type TCCheckSign
- type TCContractStorageGet
- type TCContractStoragePureGet
- type TCEcrecover
- type TCGetBalance
- type TCGetCoinbase
- type TCGetGasLimit
- type TCGetMsgTokenValue
- type TCGetMsgValue
- type TCGetNumber
- type TCGetTimestamp
- type TCGetTxGasPrice
- type TCGetTxOrigin
- type TCIssue
- type TCLog0
- type TCLog1
- type TCLog2
- type TCLog3
- type TCLog4
- type TCNotify
- type TCNow
- type TCSelfDestruct
- type TCStorageDel
- type TCStorageGet
- type TCStoragePureGet
- type TCStoragePureSetBytes
- type TCStoragePureSetString
- type TCStorageSet
- type TCStorageSetBytes
- type TCTokenAddress
- type TCTokenBalance
- type TCTransfer
- type TCTransferToken
- type TransferFunc
- type UnsafeTransferFunc
- type WASM
- func (wasm *WASM) AddOtx(br types.BalanceRecord)
- func (wasm *WASM) Call(c types.ContractRef, addr, token common.Address, input []byte, gas uint64, ...) (ret []byte, leftOverGas uint64, byteCodeGas uint64, err error)
- func (wasm *WASM) CallCode(c types.ContractRef, addr common.Address, input []byte, gas uint64, ...) (ret []byte, leftOverGas uint64, byteCodeGas uint64, err error)
- func (wasm *WASM) Cancel()
- func (wasm *WASM) Create(c types.ContractRef, data []byte, gas uint64, value *big.Int) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error)
- func (wasm *WASM) DelegateCall(c types.ContractRef, addr common.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, byteCodeGas uint64, err error)
- func (wasm *WASM) GasRate() uint64
- func (wasm *WASM) GetBlockNumber() *big.Int
- func (wasm *WASM) GetCode(bz []byte) []byte
- func (wasm *WASM) GetCoinbase() common.Address
- func (wasm *WASM) GetOTxs() []types.BalanceRecord
- func (wasm *WASM) GetStateDB() types.StateDB
- func (wasm *WASM) GetTime() *big.Int
- func (wasm *WASM) GetUTXOChangeRate(addr common.Address) (int64, error)
- func (wasm *WASM) GetUTXOChangeRatePure(addr common.Address) (uint8, error)
- func (wasm *WASM) RefundAllFee() uint64
- func (wasm *WASM) RefundFee() uint64
- func (wasm *WASM) Reset(msg types.Message)
- func (wasm *WASM) SetToken(token common.Address)
- func (wasm *WASM) StaticCall(c types.ContractRef, addr common.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, byteCodeGas uint64, err error)
- func (wasm *WASM) UTXOCall(c types.ContractRef, addr, token common.Address, input []byte, gas uint64, ...) (ret []byte, leftOverGas uint64, byteCodeGas uint64, err error)
- func (wasm *WASM) Upgrade(caller types.ContractRef, contractAddr common.Address, code []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanTransfer ¶
CanTransfer checks wether there are enough funds in the address' account to make a transfer. This does not take the necessary gas in to account to make the transfer valid.
Types ¶
type AccountRef ¶
AccountRef implements ContractRef.
Account references are used during EVM initialisation and it's primary use is to fetch addresses. Removing this object proves difficult because of the cached jump destinations which are fetched from the parent contract (i.e. the caller), which is a ContractRef.
func (AccountRef) Address ¶
func (ar AccountRef) Address() common.Address
Address casts AccountRef to a Address
type CanTransferFunc ¶
CanTransferFunc is the signature of a transfer guard function
type ChainContext ¶
type ChainContext interface { // GetHeader returns the hash corresponding to their hash. GetHeader(uint64) *types.Header }
ChainContext supports retrieving headers from the current blockchain to be used during transaction processing.
type Context ¶
type Context struct { // CanTransfer returns whether the account contains // sufficient ether to transfer the value CanTransfer CanTransferFunc // Transfer transfers ether from one account to the other Transfer TransferFunc // GetHash returns the hash corresponding to n UnsafeTransfer UnsafeTransferFunc GetHash GetHashFunc // Message information Token common.Address // Provides the tx token type Origin common.Address // Provides information for ORIGIN GasPrice *big.Int // Provides information for GASPRICE // Block information Coinbase common.Address // Provides information for COINBASE GasLimit uint64 // Provides information for GASLIMIT BlockNumber *big.Int // Provides information for NUMBER Time *big.Int // Provides information for TIME Difficulty *big.Int // Provides information for DIFFICULTY WasmGasRate uint64 }
Context provides the EVM with auxiliary information. Once provided it shouldn't be modified.
func NewWASMContext ¶
func NewWASMContext(header *types.Header, chain ChainContext, author *common.Address, gasRate uint64) Context
NewWASMContext creates a new context for use in the WASM.
type Contract ¶
type Contract struct { // CallerAddress is the result of the caller which initialised this // contract. However when the "call method" is delegated this value // needs to be initialised to that of the caller's caller. CallerAddress common.Address Code []byte CodeHash common.Hash CodeAddr *common.Address Input []byte Gas uint64 ByteCodeGas uint64 Args []byte DelegateCall bool CreateCall bool // contains filtered or unexported fields }
Contract represents an ethereum contract in the state database. It contains the the contract code, calling arguments. Contract implements ContractRef
func NewContract ¶
func NewContract(caller ContractRef, object ContractRef, value *big.Int, gas uint64) *Contract
NewContract returns a new contract environment for the execution of EVM.
func (*Contract) AsDelegate ¶
AsDelegate sets the contract to be a delegate call and returns the current contract (for chaining calls)
func (*Contract) Caller ¶
Caller returns the caller of the contract.
Caller will recursively call caller when the contract is a delegate call, including that of caller's caller.
func (*Contract) SetCallCode ¶
SetCallCode sets the code of the contract and address of the backing data object
type ContractRef ¶
ContractRef is a reference to the contract's backing object
type GetHashFunc ¶
GetHashFunc returns the nth block hash in the blockchain and is used by the BLOCKHASH EVM op code.
type TCBlockHash ¶
type TCBlockHash struct{}
type TCCallContract ¶
type TCCallContract struct{}
type TCCheckSign ¶
type TCCheckSign struct{}
type TCContractStorageGet ¶
type TCContractStorageGet struct{}
type TCContractStoragePureGet ¶
type TCContractStoragePureGet struct{}
type TCEcrecover ¶
type TCEcrecover struct{}
type TCGetBalance ¶
type TCGetBalance struct{}
type TCGetCoinbase ¶
type TCGetCoinbase struct{}
type TCGetGasLimit ¶
type TCGetGasLimit struct{}
type TCGetMsgTokenValue ¶
type TCGetMsgTokenValue struct{}
type TCGetMsgValue ¶
type TCGetMsgValue struct{}
type TCGetNumber ¶
type TCGetNumber struct{}
type TCGetTimestamp ¶
type TCGetTimestamp struct{}
type TCGetTxGasPrice ¶
type TCGetTxGasPrice struct{}
type TCGetTxOrigin ¶
type TCGetTxOrigin struct{}
type TCSelfDestruct ¶
type TCSelfDestruct struct{}
type TCStorageDel ¶
type TCStorageDel struct{}
type TCStorageGet ¶
type TCStorageGet struct{}
type TCStoragePureGet ¶
type TCStoragePureGet struct{}
type TCStoragePureSetBytes ¶
type TCStoragePureSetBytes struct{}
type TCStoragePureSetString ¶
type TCStoragePureSetString struct{}
type TCStorageSet ¶
type TCStorageSet struct{}
type TCStorageSetBytes ¶
type TCStorageSetBytes struct{}
type TCTokenAddress ¶
type TCTokenAddress struct{}
type TCTokenBalance ¶
type TCTokenBalance struct{}
type TCTransfer ¶
type TCTransfer struct{}
type TCTransferToken ¶
type TCTransferToken struct{}
type TransferFunc ¶
TransferFunc is the signature of a transfer function
type UnsafeTransferFunc ¶
type WASM ¶
type WASM struct { // Context provides auxiliary blockchain related information Context // StateDB gives access to the underlying state StateDB types.StateDB // Issued marked that WASM has called tcIssue and may be reverted because of that Issued chan bool // contains filtered or unexported fields }
func NewWASM ¶
NewWASM returns a new WASM. The returned WASM is not thread safe and should only ever be used *once*.
func (*WASM) AddOtx ¶
func (wasm *WASM) AddOtx(br types.BalanceRecord)
func (*WASM) Call ¶
func (wasm *WASM) Call(c types.ContractRef, addr, token common.Address, input []byte, gas uint64, value *big.Int) (ret []byte, leftOverGas uint64, byteCodeGas uint64, err error)
Call executes the contract associated with the addr with the given input as parameters. It also handles any necessary value transfer required and takes the necessary steps to create accounts and reverses the state in case of an execution error or failed value transfer.
func (*WASM) CallCode ¶
func (wasm *WASM) CallCode(c types.ContractRef, addr common.Address, input []byte, gas uint64, value *big.Int) (ret []byte, leftOverGas uint64, byteCodeGas uint64, err error)
CallCode executes the contract associated with the addr with the given input as parameters. It also handles any necessary value transfer required and takes the necessary steps to create accounts and reverses the state in case of an execution error or failed value transfer.
CallCode differs from Call in the sense that it executes the given address' code with the caller as context.
func (*WASM) Cancel ¶
func (wasm *WASM) Cancel()
Cancel cancels any running WASM operation. This may be called concurrently and it's safe to be called multiple times.
func (*WASM) Create ¶
func (wasm *WASM) Create(c types.ContractRef, data []byte, gas uint64, value *big.Int) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error)
Create creates a new contract using code as deployment code.
func (*WASM) DelegateCall ¶
func (wasm *WASM) DelegateCall(c types.ContractRef, addr common.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, byteCodeGas uint64, err error)
DelegateCall executes the contract associated with the addr with the given input as parameters. It reverses the state in case of an execution error.
DelegateCall differs from CallCode in the sense that it executes the given address' code with the caller as context and the caller is set to the caller of the caller.
func (*WASM) GetBlockNumber ¶
func (*WASM) GetOTxs ¶
func (wasm *WASM) GetOTxs() []types.BalanceRecord
func (*WASM) GetUTXOChangeRate ¶ added in v0.1.3
func (*WASM) GetUTXOChangeRatePure ¶ added in v0.1.3
func (*WASM) RefundAllFee ¶ added in v0.1.1
func (*WASM) Reset ¶
reset func (wasm *WASM) Reset(origin common.Address, gasPrice *big.Int, nonce uint64) {
func (*WASM) StaticCall ¶
func (wasm *WASM) StaticCall(c types.ContractRef, addr common.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, byteCodeGas uint64, err error)
StaticCall executes the contract associated with the addr with the given input as parameters while disallowing any modifications to the state during the call. Opcodes that attempt to perform such modifications will result in exceptions instead of performing the modifications.