nim-web3/tests/helpers/utils.nim

19 lines
496 B
Nim
Raw Normal View History

2023-12-06 12:59:24 +00:00
import
results,
2024-01-03 14:54:30 +00:00
chronos,
2023-12-06 12:59:24 +00:00
stew/byteutils,
../../web3,
../../web3/primitives
proc deployContract*(web3: Web3, code: string, gasPrice = 0): Future[ReceiptObject] {.async.} =
var code = code
var tr: TransactionArgs
tr.`from` = Opt.some(web3.defaultAccount)
tr.data = Opt.some(hexToSeqByte(code))
tr.gas = Opt.some Quantity(3000000)
2023-12-06 12:59:24 +00:00
if gasPrice != 0:
tr.gasPrice = Opt.some(gasPrice.Quantity)
2023-12-06 12:59:24 +00:00
let r = await web3.send(tr)
return await web3.getMinedTransactionReceipt(r)