trufflesuite / drizzle-legacy

Reactive Ethereum datastore for dapp UIs.
http://truffleframework.com/docs/drizzle/getting-started
MIT License
502 stars 129 forks source link

print revert() in new Contract function #215

Closed hany-peak closed 5 years ago

hany-peak commented 5 years ago

Truffle v5.0.10 (core: 5.0.10) Solidity v0.5.0 (solc-js) Node v10.15.0 Web3.js v1.0.0-beta.37

//solidity Code ( MyToken2 newToken = new MyToken2()) <-- errorpoint

`function deployToken(string memory _name, string memory _symbol, uint8 _decimals) public returns (bool) { MyToken2 newToken = new MyToken2(_name, _symbol, _decimals);

    tokenRegistry[msg.sender] = address(newToken);

    emit DeployedToken(msg.sender, address(newToken));

    return true;
}`

//test code [ no Error ] && REMIX IDE [ no Error ] `it("deployToken", async() => { const address = await INSTANCE_MyProxy.deployToken("COLDBREW","CB",18,{from:MyProxyIssuer});

        let _tokenAddress = await INSTANCE_MyProxy.tokenRegistry(MyProxyIssuer);
        console.log(1233132, _tokenAddress);

        const INSTANCE_MyToken2 = await MyToken2.at(_tokenAddress);

        console.log(123123123, INSTANCE_MyToken2);

        let tokenName = await INSTANCE_MyToken2.name();

        console.log('tokenName : ', tokenName);
    })`

// myProxy.js let deployTokenKey = drizzle.contracts.MyProxy.methods.deployToken .cacheSend( this.state.tokenName, this.state.tokenSymbol, parseInt(this.state.tokenDecimals), {from:this.state.issuer} );

I tried to basic Setter & getter like setName, getName. it is no Error. but i tried to new Contract function in drizzle (new MyToken2(_name, _symbol, _decimals)), result is error. and then i also tried new StandradToken(openzepp- ERC20). it's error too. 스크린샷 2019-04-08 오후 1 59 56

스크린샷 2019-04-08 오후 2 18 20

스크린샷 2019-04-08 오후 2 15 43 스크린샷 2019-04-08 오후 2 15 09

hany-peak commented 5 years ago

i was in hell for two days... just printed revert().. if you have same thing with my problem, just change gas config in your code.

it is not drizzzle's problem.

  1. I got the same error. This is due to the testprc's gas limit is not enough to process your transaction.
  2. you are correct - this error appears when you don't add the "gas" parameter to "send" method. Too bad that it is not documented anywhere...

So the correct method call should be: contract.methods.mymethod.send({from: account, gas: })

let deployTokenKey = drizzle.contracts.MyProxy.methods.deployToken .cacheSend( this.state.tokenName, this.state.tokenSymbol, parseInt(this.state.tokenDecimals), {from:this.state.issuer,gas:5000000} );

it is successed. it was test-rpc problem.