@@ -27,15 +27,16 @@ import (
2727// ErrNoCode is returned by call and transact operations for which the requested
2828// recipient contract to operate on does not exist in the state db or does not
2929// have any code associated with it (i.e. suicided).
30- //
31- // Please note, this error string is part of the RPC API and is expected by the
32- // native contract bindings to signal this particular error. Do not change this
33- // as it will break all dependent code!
3430var ErrNoCode = errors .New ("no contract code at given address" )
3531
3632// ContractCaller defines the methods needed to allow operating with contract on a read
3733// only basis.
3834type ContractCaller interface {
35+ // HasCode checks if the contract at the given address has any code associated
36+ // with it or not. This is needed to differentiate between contract internal
37+ // errors and the local chain being out of sync.
38+ HasCode (contract common.Address , pending bool ) (bool , error )
39+
3940 // ContractCall executes an Ethereum contract call with the specified data as
4041 // the input. The pending flag requests execution against the pending block, not
4142 // the stable head of the chain.
@@ -55,6 +56,11 @@ type ContractTransactor interface {
5556 // execution of a transaction.
5657 SuggestGasPrice () (* big.Int , error )
5758
59+ // HasCode checks if the contract at the given address has any code associated
60+ // with it or not. This is needed to differentiate between contract internal
61+ // errors and the local chain being out of sync.
62+ HasCode (contract common.Address , pending bool ) (bool , error )
63+
5864 // EstimateGasLimit tries to estimate the gas needed to execute a specific
5965 // transaction based on the current pending state of the backend blockchain.
6066 // There is no guarantee that this is the true gas limit requirement as other
@@ -68,7 +74,38 @@ type ContractTransactor interface {
6874
6975// ContractBackend defines the methods needed to allow operating with contract
7076// on a read-write basis.
77+ //
78+ // This interface is essentially the union of ContractCaller and ContractTransactor
79+ // but due to a bug in the Go compiler (https://github.com/golang/go/issues/6977),
80+ // we cannot simply list it as the two interfaces. The other solution is to add a
81+ // third interface containing the common methods, but that convolutes the user API
82+ // as it introduces yet another parameter to require for initialization.
7183type ContractBackend interface {
72- ContractCaller
73- ContractTransactor
84+ // HasCode checks if the contract at the given address has any code associated
85+ // with it or not. This is needed to differentiate between contract internal
86+ // errors and the local chain being out of sync.
87+ HasCode (contract common.Address , pending bool ) (bool , error )
88+
89+ // ContractCall executes an Ethereum contract call with the specified data as
90+ // the input. The pending flag requests execution against the pending block, not
91+ // the stable head of the chain.
92+ ContractCall (contract common.Address , data []byte , pending bool ) ([]byte , error )
93+
94+ // PendingAccountNonce retrieves the current pending nonce associated with an
95+ // account.
96+ PendingAccountNonce (account common.Address ) (uint64 , error )
97+
98+ // SuggestGasPrice retrieves the currently suggested gas price to allow a timely
99+ // execution of a transaction.
100+ SuggestGasPrice () (* big.Int , error )
101+
102+ // EstimateGasLimit tries to estimate the gas needed to execute a specific
103+ // transaction based on the current pending state of the backend blockchain.
104+ // There is no guarantee that this is the true gas limit requirement as other
105+ // transactions may be added or removed by miners, but it should provide a basis
106+ // for setting a reasonable default.
107+ EstimateGasLimit (sender common.Address , contract * common.Address , value * big.Int , data []byte ) (* big.Int , error )
108+
109+ // SendTransaction injects the transaction into the pending pool for execution.
110+ SendTransaction (tx * types.Transaction ) error
74111}
0 commit comments