question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Erorr on generating solidity event that has 'string indexed' argument

See original GitHub issue
  • [ v ] I’ve asked for help in the Truffle Gitter before filing this issue.

Issue

The error ‘Error: Number can only safely store up to 53 bits’ is shown when I call contact method that has ‘string indexed hello’ parameter in event. If I remove the ‘indexed’ word then it works fine. Method is called from truffle console

Steps to Reproduce

contract test { 
                uint _multiplier;
                event MultipliedLog(uint indexed a, uint indexed result, string indexed hello, address sender );

                function test(uint multiplier){
                    _multiplier = multiplier;
                }

                function multiply(uint a) returns(uint d) {
                    d = a * _multiplier;
                    MultipliedLog(a, d, "Hello world", msg.sender);
                    return d;
                }
            }

truffle(development)> migrate truffle(development)> var c = test.at(test.address) truffle(development)> c.address ‘0x345ca3e014aaf5dca488057592ee47305d9b3e10’ truffle(development)> c.multiply(18)

Expected Behavior

Method call should not fail. It works OK when is called from nethereum (.net c#)

Actual Results

Error: Number can only safely store up to 53 bits at assert (C:\Users\vlukanin\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:228025:21) at BN.toNumber (C:\Users\vlukanin\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:228525:7) at C:\Users\vlukanin\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:182430:59 at Array.forEach (<anonymous>) at decodeParams (C:\Users\vlukanin\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:182426:9) at Object.decodeEvent (C:\Users\vlukanin\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:182471:10) at C:\Users\vlukanin\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:317971:38 at Array.map (<anonymous>) at Object.decodeLogs (C:\Users\vlukanin\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:317942:19) at Object.callback (C:\Users\vlukanin\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:318070:35) truffle(development)> test.deployed().then(function(instance){instance.exit SyntaxError: Unexpected end of input at createScript (vm.js:80:10) at Object.runInContext (vm.js:119:10) at Console.interpret (C:\Users\vlukanin\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:200887:17) at ReplManager.interpret (C:\Users\vlukanin\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:201603:18) at bound (domain.js:301:14) at REPLServer.runBound [as eval] (domain.js:314:12) at REPLServer.onLine (repl.js:441:10) at emitOne (events.js:116:13) at REPLServer.emit (events.js:211:7) at REPLServer.Interface._onLine (readline.js:282:10)

Environment

  • Operating System: Windows 10
  • Truffle version: 4.0.1
  • Ethereum client: truffle develop. Same issue when using Ganache
  • node version: 8.9.1
  • npm version: 5.5.1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
selfresonatorcommented, Jan 12, 2018

Hopefully I’m not missing something painfully obvious here, especially since this is my first time open source GitHub issuing! Anyway:

Contract

contract Elections is Ownable {
  event SendElection(string name, string description);

  function getElection() public {
    SendElection(electionList[0].name, electionList[0].description);
  }
}

In development console:

> compile
> migrate
> Elections.at("0x2a50...").createElection("Treasurer", "Run the Treasury!");
> Elections.at("0x2a50...").getElection(function(result){return result})

Error that runs both through the client and the development console:

BigNumber Error: new BigNumber() not a number: function (result){return result}
    at raise (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:45276:25)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:45264:33
    at new BigNumber (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:44292:67)
    at new BigNumber (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:44302:25)
    at toBigNumber (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:8991:12)
    at Object.toTwosComplement (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:9002:21)
    at SolidityTypeAddress.formatInputInt [as _inputFormatter] (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:28380:38)
    at SolidityTypeAddress.SolidityType.encode (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:32746:17)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:69251:29
    at Array.map (native)

Whether I’m running this from the development console or a client, I shouldn’t be getting this error. I should only receive a callback in my event listener for SendElection() with either an error or the event. Correct? I know the elections are there by checking the length of the electionsArray I store them in.

0reactions
cgeweckecommented, Jan 25, 2018

@v-lukanin Apologies but I’m going to close this again for house-keeping. The error comes from one of our dependencies and is a long-standing issue there. Hopefully there will be a resolution in the future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

solidity - Indexed Event with string not getting logged
The combination of string and indexed does not work. To understand why, see how event arguments are stored in the blockchain.
Read more >
How to decode the indexed string param in an event using ...
Okay so I just found out "If the index parameter is a string, bytes or array than the keccak-256 hash of is the...
Read more >
Contracts — Solidity 0.8.17 documentation
All parameters without the indexed attribute are ABI-encoded into the data part of the log.
Read more >
“Stack Too Deep”- Error in Solidity - Medium
This analysis shows that an event with one argument prevents one variable of being used, because topic0 is placed in the stack before...
Read more >
Interface - Ethers.js
Create a new Interface from a JSON string or object representing abi. ... address indexed to, uint256 amount)", // A Custom Solidity Error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found