Closed LouisRandaxhe closed 1 year ago
I have the same problem.
Hi,
I would like to be able to do the same.
I am trying to transact with an eth contract method that take an address[] memory in arguments. When I try to pass this array in args of transact_and_wait in my rails app, I have the following error : Could not parse address: ["...", "...", ...].
Thank you for your work.
Thanks for raising this. Could you show me an example contract or transaction that causes this issue?
Hello,
Here is the Solidity contract function signatures :
function distributeNewIncome(uint amount, address[] memory validAddresses) public
And here is how I call it in my Rails app :
@eth = Ethereum.new #instantiate my Ethereum.rb class (see below)
def distribute_income_to_users(contract_address, amount)
begin
contract = get_contract(contract_address)
valid_addresses = Wallet.all.select{|w| w.user.kyc.accepted?}.map{|w| w.eth_address}.to_a #I tried with an array and an array.to_s
@eth.transact_with_contract(contract,"distributeNewIncome", amount, valid_addresses)
rescue => e
raise e
end
end
Finally here is the 'transact_with_contract' in my Ethereum.rb file :
@client = Eth::Client.create Parameter.find_by_key("eth_endpoint").value #connection to polygon test network with endpoint saved in db
def transact_with_contract(contract, method, *args) #transaction with contract
begin
puts '---Begin transaction---'
hash = @client.transact_and_wait(contract, method, *args, sender_key: @key, legacy: true, gas_limit: 4000000)
raise "---Transaction not mined---" unless @client.is_mined_tx?(hash)
hash
rescue => e
raise '---Error---'
end
end
Do you have any idea when you can solve the problem please?
Thank you very much!
I really need to work with your gem and I'm still stuck with this issue.
Will you have time to solve the problem soon?
Thanks a lot!
I really need to work with your gem and I'm still stuck with this issue.
Will you have time to solve the problem soon?
Thanks a lot!
should be fixed after #194 #191 #185
geth = Client.create "/tmp/geth.ipc"
# => #<Eth::Client::Ipc:0x000055a8e12bccc8 @gas_limit=21000, @id=0, @max_fee_per_gas=0.4269e11, @max_priority_fee_per_gas=0.101e10, @path="/tmp/geth.ipc">
contract = Contract.from_file file: "spec/fixtures/contracts/address_storage.sol"
# => #<Eth::Contract::AddressStorage:0x000055a8e1116b30>
geth.deploy_and_wait contract
# => "0x7aD1FF3AFcA45262C22E32367fAF1B91e24A0909"
geth.call(contract, "retrieveMyAddress")
# => "0x0000000000000000000000000000000000000000"
geth.transact_and_wait(contract, "storeMyAddress", Key.new.address.to_s)
# => "0x5a6728574db598f515e2f93b872d73239efa0470672487325888ce71062835aa"
geth.call(contract, "retrieveMyAddress")
# => "0xbdc4d90b1d46353eb65eca3d0aeb968039f8aa9d"
geth.transact_and_wait(contract, "storeMyArray", [Key.new.address.to_s, Key.new.address.to_s])
# => "0x661ea3fdfdcca66832898917790ea104e54b25753eeb219a5a2b3e7f842005d5"
geth.call(contract, "retrieveMyArray", 0)
# => "0xae2cbef824c78274c6a4910461658e8a390cd9ce"
geth.call(contract, "retrieveMyArray", 1)
# => "0xdd902b8e5d69c08c914c94acc2c1115b6ed74029"
Hello, I am trying to transact with an eth contract method that take an address[] memory in arguments.
When I try to pass this array in args of transact_and_wait in my rails app, I have this error : Could not parse address: ["...", "...", ...].
How can I solve that problem ?