Skip to main content
8 votes

BNF grammar definition for Solidity

I wrote an ANTLR4 grammar for Solidity that you may find useful: https://github.com/solidityj/solidity-antlr4 It can generate parsers in any of the ANTLR supported targets and it has full support ...
Federico B.'s user avatar
7 votes

Parsing contract endpoint output

The length of the string is the word after the one you have identified as status. So for asset1 it is 0x16 = 22 in decimal, and for asset2 it is 0xc9 = 201 decimal. Strings are dynamic types and ...
benjaminion's user avatar
  • 9,317
6 votes

Convert ABI to Solidity code

Here is a tool that takes an ABI and convert it to its Solidity interface: https://bia.is/tools/abi2solidity/ Source code is published on GitHub: https://github.com/maxme/abi2solidity/
Maxime's user avatar
  • 181
4 votes

How to decode uniswap v3 Router 2 transaction

After some more digging, I found out this article, which explained how to get some data out of the input attribute of the transaction (no transaction logs required). See below the function that takes ...
Tofig Hasanov's user avatar
3 votes

How can I check if an Ethereum address is valid by using zod parser?

From zod docs: Zod lets you provide custom validation logic via refinements. In order to achieve this you may want first to define a zod schema by using the refine() function in combination with ...
Sevamove's user avatar
3 votes

How to build an AST for Solidity?

In addition to chriseth's answer, there's also the solidity-parser project which is useful if you A) are developing in a Javascript context, or B) don't want the parser to error if there are ...
Tim Coulter's user avatar
  • 1,049
2 votes

BNF grammar definition for Solidity

Here's yet another link pointing to the solidity documentation: http://solidity.readthedocs.io/en/develop/miscellaneous.html#language-grammar
Karl Guggisberg's user avatar
2 votes

How to build an AST for Solidity?

In addition to Tim's answer there's also a python-solidity-parser based on the ANTLR syntax and AST format used in solidity-parser-antlr that you can use if you want to avoid depending on the compiler....
tintin's user avatar
  • 275
2 votes

Parsing contract method output as an array of fields

If you want to do it in NodeJs, you can create a file named decodeParams.js and which contains: #!/usr/bin/nodejs const Web3 = require("web3"); const web3 = new Web3(); const Coder = require("./...
Xavier Leprêtre B9lab's user avatar
2 votes
Accepted

Convert address to string after solidity 0.5.x

Try this out. pragma solidity > 0.5.1; contract Test { function test() public view returns (string memory) { return addressToString(address(...
Micky Socaci's user avatar
  • 1,312
2 votes
Accepted

jq and vm fail to parse json

You can see in the Foundry docs, that vm.ffi() calls an arbitrary command only if ffi is enabled. You can enable the same by making its value as true in the foundry.toml file, by adding this line: ffi ...
SYED ASAD KAZMI's user avatar
2 votes
Accepted

Is there any way how to check if transaction contains incoming ETH?

You need some RPC node provider, which supports traces, to get so-called "internal transactions". For example - debug_traceTransaction You'll get the internal call tree, and you look there ...
tenbits's user avatar
  • 2,498
1 vote

Convert ABI to Solidity code

grabABI, which is part of QuickBlocks, comes very close. It's open source, so you could modify it slightly to surround its output with the contract part and add the squiggles after each function, but ...
Thomas Jay Rush's user avatar
1 vote

Parser error expected " but got indentifer

I created new contract named Test.sol and added your code "edited". It now compiles. Though there are many warnings about unused variables. But that is okay for learning code. pragma ...
Sky's user avatar
  • 2,400
1 vote

I get a Parser error "Expected identifier but got 'public' "

From the question contract I can say that it wont compile given the position of the public keyword, should look like this: pragma solidity ^0.4.13; contract nietTeveel{ uint ...
Julissa DC's user avatar
  • 1,965
1 vote

ParserError: Source "@openzeppelin/contracts/token/ERC20/ERC20.sol" not found:

Try using import "OpenZeppelin/[email protected]/contracts/token/ERC20/ERC20.sol"; '@' is not required anymore you can specify the same in your .yaml files(remappings).
Shantanu Jha's user avatar
1 vote

ParseError: Expected ';' but got '(' emit sent(_from, _to, _value);^

You are emitting the event at the very beginning of your code, whereas you should be defining it by using the event keyword (that's why you get an error). And then, you are just calling the event ...
Sergi Juanati's user avatar
1 vote
Accepted

ParseError: Expected ';' but got '(' emit sent(_from, _to, _value);^

You are creating and calling the event the wrong way. Keyword event is used when you initialize the event and keyword emit is used when you're firing the event, look at this example: pragma solidity ^...
Miroslav Nedelchev's user avatar
1 vote

Blockchain structure with smart contracts and access data

Smart contract code (EVM bytecode, in the case of Ethereum) is "uploaded" to the blockchain in the deployment transaction of a smart contract. The contract gets its own address, similar to Ethereum ...
Mikko Ohtamaa's user avatar
1 vote

Solidity IDE Parser Error on Token Name

There’s a different quotation mark opening the string assigned to name. name = **“**DoubleHappiness";
pabloruiz55's user avatar
  • 7,686
1 vote

Is there a current (11/2017) way to parse the Ethereum blockchain?

You can try QuickBlocks. It's C++, not Python, but it fully supported and actively developed: https://github.com/Great-Hill-Corporation/quickBlocks
Thomas Jay Rush's user avatar
1 vote

Parsing contract method output as an array of fields

Well, I found the answer myself... just a juxtaposition of fields like this, in PHP code: list($_field1, $_field2, $_field3, $_zeros, $_field4, $_field5) = sscanf($output, "0x%64s%64s%64s%24s%40s%s");...
Juan Ignacio Pérez Sacristán's user avatar
1 vote

Parse contract to retrieve declared identifiers

You can use ConsenSys/solidity-parser and walk the resulting AST looking for variable declarations. There are no visitors included in the package, so you will have to write one yourself.
Federico B.'s user avatar
1 vote
Accepted

How can I easily parse a raw transaction?

Check here: https://rawtxdecode.in/. It supports all Ethereum txs types.
1 vote

How can I easily parse a raw transaction?

is ethereumjs-tx-unsign along the lines of what you're hoping to accomplish? if so.. and you're also interested in obtaining even more information (from the signature), then the unsign() function in ...
1 vote

How to parse blocks with Python?

Your geth node will also act as a JSON-RPC server. You can use the APIs wiki page to crawl the blockchain and extract block data. Here is an interesting git repo that you could fork. It's a bit show ...
Baddar's user avatar
  • 11
1 vote

How to build an AST for Solidity?

Use flag --ast-compact-json, which gives the "AST of all source files in a compact JSON format." solc --ast-compact-json contract.sol
Martin Monperrus's user avatar
1 vote

How to build an AST for Solidity?

I have used 3 tools, maybe you can try: https://github.com/iamdefinitelyahuman/py-solc-ast https://github.com/ConsenSys/solc-typed-ast https://github.com/ethereum/solidity/tree/develop/docs/grammar
smart contract_research_Rookie's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible