Skip to content

Commit 4097ba6

Browse files
derekgkaralabe
authored andcommitted
mobile: add ability to create transactions for deploying contracts (#16104)
1 parent 26aea73 commit 4097ba6

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎mobile/types.go‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,18 @@ type Transaction struct {
197197
tx *types.Transaction
198198
}
199199

200-
// NewTransaction creates a new transaction with the given properties.
200+
// NewContractCreation creates a new transaction for deploying a new contract with
201+
// the given properties.
202+
func NewContractCreation(nonce int64, amount *BigInt, gasLimit int64, gasPrice *BigInt, data []byte) *Transaction {
203+
return &Transaction{types.NewContractCreation(uint64(nonce), amount.bigint, uint64(gasLimit), gasPrice.bigint, common.CopyBytes(data))}
204+
}
205+
206+
// NewTransaction creates a new transaction with the given properties. Contracts
207+
// can be created by transacting with a nil recipient.
201208
func NewTransaction(nonce int64, to *Address, amount *BigInt, gasLimit int64, gasPrice *BigInt, data []byte) *Transaction {
209+
if to == nil {
210+
return &Transaction{types.NewContractCreation(uint64(nonce), amount.bigint, uint64(gasLimit), gasPrice.bigint, common.CopyBytes(data))}
211+
}
202212
return &Transaction{types.NewTransaction(uint64(nonce), to.address, amount.bigint, uint64(gasLimit), gasPrice.bigint, common.CopyBytes(data))}
203213
}
204214

0 commit comments

Comments
 (0)