Sorry in advance for my english I am French :)
I try to create a simple ethereum wallet. The idea is to allow the user to create a contract and to interact with it. I am using meteor, web3 and an testRPC node.
Basically for the interactions with the contract, for each contract I print on the browser the list of its functions . The user has just to click on the function he wants, then a pop up is printed to retrieve the arguments of the functions. Then I use web3 to send the request to a testRPC node and use a callback to print the result for the user.
The problem is that basically I don't obviously know in advance what is the function and the arg. So I index each of my html file with a special number and in combination with the dataBase, I retrieve the address of the contract, and all the informations about the function (using the ABI). Then I create three variables :
- a variable
contract
- a variable
functionPrototype = abi of my function
- a dictionary
args = {nameArg1 : arg1, nameArg2 : arg2 etc...}
which contains my arguments.
Then I have the contract, the name of the function and the args.
If the original Solidity function is :
function whatever(type nameArg1, type nameArg2) public{}
I would like to use the following web3 function to send my request:
contract[functionPrototype.name](args, {from: account, gas: 350000}, function(err, result){})
But this request doesn't work . The following request, when I write all the args, works :
contract[functionPrototype.name](arg1, arg2, {from: account, gas: 350000}, function(err, result){})
So the people can say : why you don't use the second request?
Because there are an infinite number of functions and I can't write all the arguments for each function. I need to automate all the process, so basically retrieve the arg and the name of the functions and using as input a dictionary or an array.
I have tried to use the function apply
, with an array but it doesn't work either. I have all the time a WebSocket is closed due to suspension.
So do you know how I can send my arguments using a dictionary or an array to a solidity function?
Merci beaucoup!!!
And good luck for your jobs