1

I did all modification related to this instruction https://github.com/tabookey/tabookey-gasless

However, when I'm trying to write some tests it fails and provides me the following error

     Error: No relay responded! 4 attempted, 4 pinged
      at RelayClient.relayTransaction (node_modules/tabookey-gasless/src/js/relayclient/relayclient.js:264:15)
      at processTicksAndRejections (internal/process/next_tick.js:81:5)

the logs are

relayTransaction: req: from:0xc.....
to:0x8f.....
encodedFunctionCall:0xa9059cbb0000000000000000000000000949d494a5ca5afdbd2881d58b3804d9382a48db0000000000000000000000000000000000000000000000000000000000000064
gasPrice:2000000000
gasLimit:65000
nonce:0
relayhub:0x1349584869A1C7b8dc8AE0e93D8c15F5BB3B4B87
relayAddress:0x5b747ee070f18463e86ef08485e5115d82b675b9
relayTransaction: [object Object]
One batch of relays failed, last error:  No response matched filter from any server: [object Object]

Here is an implemented code:

    var tabookey = require('tabookey-gasless');
    var provider = new tabookey.RelayProvider(web3.currentProvider, {});

    it("test transfer gas free", async function() {

        web3.setProvider(provider);

        let initBalance = await web3.eth.getBalance(account_one)

        let tokenTestAddress = "0x8......."
        let tokenTestRelay = await new web3.eth.Contract(Token._json.abi, tokenTestAddress); 
        let result = await tokenTestRelay.methods.transfer(account_two, 100).send({ from: account_one, gasPrice: 2000000000, gasLimit: 65000});
    });

I use Ropsten network for tests relayHub is 0x1349584869A1C7b8dc8AE0e93D8c15F5BB3B4B87

I sent funds for one of the relay addressed, however, this does not help.

0

So found the reason:

1. The contract should be deployed

2. You need to send a deposit

you can implement own function in your contract.sol

    function deposit() public payable {
        get_relay_hub().depositFor.value(msg.value)(address(this));
    }

or use external script like http://gsn.tabookey.com/webtools/contractmanager.html

3. For tests you need to setup provider in a special for tests way example from taboo key team tabookey-gasless repo


web3.setProvider(provider);
NOTE: in real application its enough to set the provider in web3.
however, in Truffle, all contracts are built BEFORE the test have started, and COPIED the web3,
so changing the global one is not enough...
TokenContract.web3.setProvider(relayProvider) - should be for tests only

Here is an example gist

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.