NewContract returns a new contract environment for the execution of EVM.
(caller ContractRef, object ContractRef, value *big.Int, gas uint64)
| 66 | |
| 67 | // NewContract returns a new contract environment for the execution of EVM. |
| 68 | func NewContract(caller ContractRef, object ContractRef, value *big.Int, gas uint64) *Contract { |
| 69 | c := &Contract{CallerAddress: caller.Address(), caller: caller, self: object, Args: nil} |
| 70 | |
| 71 | if parent, ok := caller.(*Contract); ok { |
| 72 | // Reuse JUMPDEST analysis from parent context if available. |
| 73 | c.jumpdests = parent.jumpdests |
| 74 | } else { |
| 75 | c.jumpdests = make(destinations) |
| 76 | } |
| 77 | |
| 78 | // Gas should be a pointer so it can safely be reduced through the run |
| 79 | // This pointer will be off the state transition |
| 80 | c.Gas = gas |
| 81 | // ensures a value is set |
| 82 | c.value = value |
| 83 | |
| 84 | return c |
| 85 | } |
| 86 | |
| 87 | // AsDelegate sets the contract to be a delegate call and returns the current |
| 88 | // contract (for chaining calls) |