2023-12-06 12:59:24 +00:00
|
|
|
import
|
2024-06-11 23:32:06 +00:00
|
|
|
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
|
2024-03-20 04:12:59 +00:00
|
|
|
var tr: TransactionArgs
|
2024-06-11 23:32:06 +00:00
|
|
|
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:
|
2024-06-11 23:32:06 +00:00
|
|
|
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)
|