I have a token, and a service contract. I implemented the token based on ERC677, and tried to use
transferAndCall to call my service contract.
In my service contract, there will be several methods can be called, like
buyA(uint count, string comment),
rewardBB(uint amount, string comment).
In my understanding, in the client side, I need to wrap the method name and params as a bytes with web3 api, then in the service contract, unwrap this data, get method name, and call corresponding method with the params data.
But I got some trouble in these 2 places:
1. how to wrap/unwrap the data
2. for some reason, I need to use the param type of
string, which is dynamic, when I tested the following code, but the passed string param is alway empty. When I tried with type like bytes30, it can work.
bytes4 methodId = bytes4(keccak256("rewardBB(uint5,string)")); require(_service.call(methodId, 100, "some string of params."));
Any advice would be very appreciated. Thanks.