Rln relay/membership contract (#359)

* updates test_waku_rln_relay

* adds contract's constructor input support

* adds contracts bytecodes
This commit is contained in:
Sanaz Taheri Boshrooyeh 2021-02-04 12:10:25 -08:00 committed by GitHub
parent 4f9a838668
commit 6c7515115d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 128 additions and 68 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,17 @@
import web3, chronos, options, stint
proc deployContract*(web3: Web3, code: string, gasPrice = 0): Future[ReceiptObject] {.async.} =
proc deployContract*(web3: Web3, code: string, gasPrice = 0, contractInput = ""): Future[ReceiptObject] {.async.} =
# the contract input is the encoded version of contract constructor's input
# use nim-web3/encoding.nim module to find the appropriate encoding procedure for different argument types
# e.g., consider the following contract constructor in solidity
# constructor(uint256 x, uint256 y)
#
# the contractInput can be calculated as follows
# let
# x = 1.u256
# y = 5.u256
# contractInput = encode(x).data & encode(y).data
# Note that the order of encoded inputs should match the order of the constructor inputs
let provider = web3.provider
let accounts = await provider.eth_accounts()
@ -9,7 +20,7 @@ proc deployContract*(web3: Web3, code: string, gasPrice = 0): Future[ReceiptObje
code = "0x" & code
var tr: EthSend
tr.source = web3.defaultAccount
tr.data = code
tr.data = code & contractInput
tr.gas = Quantity(3000000000000).some
if gasPrice != 0:
tr.gasPrice = some(gasPrice)

File diff suppressed because one or more lines are too long