Documentation ¶
Index ¶
- type AccountRef
- type Contract
- func (c *Contract) Address() string
- func (c *Contract) AsDelegate() *Contract
- func (c *Contract) Caller() string
- func (c *Contract) GetByte(n uint64) byte
- func (c *Contract) SetCallCode(addr string, hash common.Hash, code []byte)
- func (c *Contract) SetCode(hash common.Hash, code []byte)
- func (c *Contract) Value() uint64
- type Ref
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountRef ¶
type AccountRef string
AccountRef 账户对象引用 (实现了合约对象引用ContractRef接口) 因为在合约调用过程中,调用者有可能是外部账户,也有可能是合约账户,所以两者的结构是互通的
type Contract ¶
type Contract struct { // 调用者地址,应该为外部账户的地址 // 如果是通过合约再调用合约时,会从上级合约中获取调用者地址进行赋值 CallerAddress string // 合约代码和代码哈希 Code []byte CodeHash common.Hash // 合约地址以及输入参数 CodeAddr string Input []byte // 委托调用时,此属性会被设置为true DelegateCall bool // contains filtered or unexported fields }
Contract 合约对象,它在内存中表示一个合约账户的代码即地址信息实体 每次合约调用都会创建一个新的合约对象
func NewContract ¶
NewContract 创建一个新的合约调用对象 不管合约是否存在,每次调用时都会新创建一个合约对象交给解释器执行,对象持有合约代码和合约地址
func (*Contract) AsDelegate ¶
AsDelegate 设置当前的合约对象为被委托调用 返回当前合约对象的指针,以便在多层调用链模式下使用
func (*Contract) Caller ¶
Caller 返回合约的调用者 如果当前合约为委托调用,则调用它的不是外部账户,而是合约账户,所以此时的caller为调用此合约的合约的caller 这个关系可以一直递归向上,直到定位到caller为外部账户地址
func (*Contract) SetCallCode ¶
SetCallCode 设置合约代码和代码哈希
Click to show internal directories.
Click to hide internal directories.