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 ...
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 ...
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/
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 ...
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 ...
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 ...
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
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....
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("./...
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(...
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 ...
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 ...
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 ...
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 ...
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 ...
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).
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 ...
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 ^...
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 ...
1
vote
Solidity IDE Parser Error on Token Name
There’s a different quotation mark opening the string assigned to name.
name = **“**DoubleHappiness";
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
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");...
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.
1
vote
Accepted
How can I easily parse a raw transaction?
Check here: https://rawtxdecode.in/. It supports all Ethereum txs types.
Community wiki
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 ...
Community wiki
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 ...
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
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
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
parser × 43solidity × 22
error × 10
blockchain × 5
contract-development × 3
remix × 3
python × 3
cpp-ethereum × 3
string × 3
go-ethereum × 2
erc-20 × 2
uniswap × 2
ethers.js × 2
transactions × 1
tokens × 1
ether × 1
contract-invocation × 1
etherscan × 1
addresses × 1
evm × 1
arrays × 1
oracles × 1
abi × 1
blocks × 1
solc × 1