MCPcopy Create free account
hub / github.com/CPChain/chain / NewContract

Function NewContract

core/vm/contract.go:68–85  ·  view source on GitHub ↗

NewContract returns a new contract environment for the execution of EVM.

(caller ContractRef, object ContractRef, value *big.Int, gas uint64)

Source from the content-addressed store, hash-verified

66
67// NewContract returns a new contract environment for the execution of EVM.
68func 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)

Callers 8

TestStoreCaptureFunction · 0.85
callMethod · 0.85
callCodeMethod · 0.85
delegateCallMethod · 0.85
StaticCallMethod · 0.85
CreateMethod · 0.85
testPrecompiledFunction · 0.85
benchmarkPrecompiledFunction · 0.85

Calls 1

AddressMethod · 0.65

Tested by 3

TestStoreCaptureFunction · 0.68
testPrecompiledFunction · 0.68
benchmarkPrecompiledFunction · 0.68