• Stars
    star
    136
  • Rank 267,629 (Top 6 %)
  • Language
    JavaScript
  • Created over 8 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Solidity Parser in Javascript

npm npm Build Status

⚠️ DEPRECATION NOTICE ⚠️

This library is not being maintained anymore. For an up-to-date Solidity parser, check out solidity-parser-antlr.

Solidity Parser

A Solidity parser in Javascript. So we can evaluate and alter Solidity code without resorting to cruddy preprocessing.

Usage

Library

npm install solidity-parser

Then, in your code:

var SolidityParser = require("solidity-parser");

// Parse Solidity code as a string:
var result = SolidityParser.parse("contract { ... }");

// Or, parse a file:
var result = SolidityParser.parseFile("./path/to/file.sol");

You can also parse a file specifically for its imports. This won't return an abstract syntax tree, but will instead return a list of files required by the parsed file:

var SolidityParser = require("solidity-parser");

var result = SolidityParser.parseFile("./path/to/file.sol", "imports");

console.log(result);
// [
//   "SomeFile.sol",
//   "AnotherFile.sol"
// ]

Command Line (for convenience)

$ solidity-parser ./path/to/file.js

Results

Consider this solidity code as input:

import "Foo.sol";

contract MyContract {
  mapping (uint => address) public addresses;
}

You'll receiving the following (or something very similar) as output. Note that the structure of mappings could be made more clear, and this will likely be changed in the future.

{
  "type": "Program",
  "body": [
    {
      "type": "ImportStatement",
      "value": "Foo.sol"
    },
    {
      "type": "ContractStatement",
      "name": "MyContract",
      "is": [],
      "body": [
        {
          "type": "ExpressionStatement",
          "expression": {
            "type": "DeclarativeExpression",
            "name": "addresses",
            "literal": {
              "type": "Type",
              "literal": {
                "type": "MappingExpression",
                "from": {
                  "type": "Type",
                  "literal": "uint",
                  "members": [],
                  "array_parts": []
                },
                "to": {
                  "type": "Type",
                  "literal": "address",
                  "members": [],
                  "array_parts": []
                }
              },
              "members": [],
              "array_parts": []
            },
            "is_constant": false,
            "is_public": true
          }
        }
      ]
    }
  ]
}

Test

In a checkout of the project, run:

$ npm test

License

MIT

More Repositories

1

rimble-ui

React components that implement Rimble's Design System.
JavaScript
462
star
2

MultiSigWallet

Ethereum MultiSigWallet
Solidity
321
star
3

curationmarkets

129
star
4

web3studio-bootleg

The Shared Royalty Non-Fungible Token (a.k.a Bootleg) is an open source project started by the ConsenSys Web3Studio team. The purpose of the Shared Royalty Non-Fungible Token (SRNFT) is to make any royalty business model, from the oil and gas industry to entertainment, easy to manage with the Ethereum blockchain .
JavaScript
91
star
5

live-libs

Providing reusable Solidity libraries that are live on the Ethereum blockchain.
JavaScript
87
star
6

cava

ConsenSys core libraries for Java & Kotlin
Java
83
star
7

Ethereum-Development-Best-Practices

A wiki containing current best practices
81
star
8

hooked-web3-provider

[DEPRECATED] see README for alternatives
JavaScript
74
star
9

Stow-Smart-Contracts

Formerly Linnia-Smart-Contracts
JavaScript
56
star
10

dao-wars

JavaScript
49
star
11

dapp-ecosystem-map

Landscape of blockchain-based end-user applications and platforms
49
star
12

ipfs.js

Wrapper for node-ipfs-api
JavaScript
45
star
13

linnia-resources

Various documents and resources for the stow protocol
42
star
14

ether-crawler

Wouldn't you like to know.
JavaScript
39
star
15

dapp-store-contracts

JavaScript
38
star
16

rimble-web3-components

React components for web3 that help developers build dApps faster with better user experiences
JavaScript
35
star
17

stow-resources

📦🔐An intro to the Stow Protocol, a permissions & encryption layer for any storage solution
35
star
18

py-eip712-structs

EIP712 data structure management for python
Python
35
star
19

Flare

Decentralized Processing using Spark and Ethereum
JavaScript
32
star
20

reflux-tx

Reflux store and a component wrapper to connect React components with Ethereum transaction states
JavaScript
31
star
21

web3studio-sojourn

A React Native DevKit with code for a Web3 Decentralized Data Storage Pattern.
JavaScript
31
star
22

real-estate-standards

JavaScript
26
star
23

contract-viewer

React component: Solidity contract viewer beautified with syntax highlight and code indentation
JavaScript
21
star
24

example-truffle-library

Example project showing how to use Truffle to create javascript libraries.
JavaScript
19
star
25

stow-js

Stow JavaScript API -- Formerly linnia-js
JavaScript
19
star
26

singulardtv-contracts

Python
19
star
27

stow-box

Formerly Linnia-box Starter kit for stow protocols for building Decentralized React Apps
JavaScript
15
star
28

Local-Raiden

Run a local Raiden network in docker containers for demo and testing purposes.
JavaScript
15
star
29

rb-relay

WorkInProgress Contract on Ropsten that verifies Rinkeby transactions
JavaScript
14
star
30

kittybrowser

Coding challenge for front-end dev candidates
JavaScript
13
star
31

Express-Web3-API

Express Web3 API to access contract functions more easily in hybrid app build
JavaScript
12
star
32

india-training

India training scripts
JavaScript
11
star
33

dex-mobile

FX trading ERC20 tokens on a mobile dapp
JavaScript
11
star
34

kubernetes-azure

📋 🔵 Setup your kubernetes cluster in Azure using its CLI
Shell
10
star
35

research

Intended as an open dialogue of cross pollination and collaborative effort to work with researchers.
TeX
10
star
36

bentobox

Asks an ethereum node for its contents (block, tx, logs, topics) dump them into a PSQL
Go
9
star
37

web3studio-dONT

Decentralized Off-chain Non-Transferable (assets)
Haskell
9
star
38

storm

Cluster deployment and cloud management tool with docker-machine
Python
9
star
39

ipfs-cluster-k8s-sidecar

Sidecar to configure ipfs-cluster replica set or statefulset using Kubernetes
JavaScript
8
star
40

blockapps-web3

BlockApps Web3 Provider
JavaScript
8
star
41

BreakableBond

A design for Ethereum contracts inspired by chemical bonds
8
star
42

transaction-monad

Compose computation that depends on an Ethereum transaction
JavaScript
8
star
43

design-system-website

Public facing website for Rimble Design System
JavaScript
7
star
44

identity-provider

JavaScript
7
star
45

bounties.network

the website for bounties.network
CSS
7
star
46

addresstoip

Ethereum contracts for mapping Ethereum addresses to IP addresses
Python
7
star
47

hellhound-vm

Go
7
star
48

robot-sapo

Watching the blockchain, reporting to slack
JavaScript
7
star
49

solc-vm

Wrapper for different solc versions
JavaScript
6
star
50

etherloan-site

Etherloan WebSite
CSS
6
star
51

kafka-deadletter

A library that adds 'dead letter' functionality to spring kafka listeners.
Java
6
star
52

ens-namehash-py

A python implementation of the namehash algorithm from EIP137
Python
6
star
53

Fae

A functional smart contract system
Haskell
6
star
54

balanc3-crypto-trade-parser

Easy trade history parser for several exchanges' CSV exports
JavaScript
6
star
55

artifaqt

Artifaqts in Prague for Devcon4
JavaScript
6
star
56

rimble-utils

Library that provides functions and data needed for smart web3 components
JavaScript
6
star
57

ConsenSys.github.io

ConsenSys Corporate Info
HTML
6
star
58

EnterpriseZK

Applied R&D aimed at bringing Zero Knowledge technology to various industries.
Go
6
star
59

rimble-icons

Cryptocurrency icons and Material app icons for React with styled-components
JavaScript
6
star
60

sirius-react-boilerplate

JavaScript
5
star
61

keyserver

Lightwallet Keyserver
JavaScript
5
star
62

connected-profiles

JavaScript
5
star
63

eth-stdlib

Standard Library for Ethereum
JavaScript
5
star
64

CSI-Dapp-Template

Application template to make things easier to build
JavaScript
5
star
65

sobol-client

⛔️DEPRECATED - package has moved to https://www.npmjs.com/package/@sobol/client
JavaScript
5
star
66

SensuiMod

Modded Sensui to enable smart contract methods to be used and paid for by service address. Meta transaction is made on the service (instead of being sent to the service) and only the inputs and the method name are sent to the API to initiate the transaction (as well as any authToken).
JavaScript
5
star
67

daorectory

TypeScript
4
star
68

sdo-training

Ethereum core concepts demonstration, applied to multiple languages
C#
4
star
69

web3studio-projects

Discussion board for web3studio projects
4
star
70

web3studio-standards

Standards repo for sharable linting and configuration tools
JavaScript
4
star
71

repsys-contracts

RepSys :: Contracts
JavaScript
4
star
72

gozos

Golang Wrapper for ZeppelinOS
Go
3
star
73

stow-json-file-generator

A fake data json file generator
JavaScript
3
star
74

quip-projects

Python
3
star
75

upgradable-eip20

upgradable EIP20 Token Standard contracts
JavaScript
3
star
76

etherMAX

On-blockchain contest for solving knapsack problems
JavaScript
3
star
77

logl

A simple Java logging framework for libraries
3
star
78

janus-example

JavaScript
2
star
79

stow-json-validator

stow-json-validator to be used for IRIS score oracles
JavaScript
2
star
80

addresstourl

Ethereum contract for mapping Ethereum addresses to URLs
Python
2
star
81

meridio-contracts

JavaScript
2
star
82

eslint-config-web3studio

standard config and boilerplate for web3studio projects
JavaScript
2
star
83

evoke

JavaScript
2
star
84

block6

Block 6: Hacker's Night
JavaScript
2
star
85

LuxarityFrontEnd

Donor dashboard for second hand clothes buyers to redeem their tokenized orders and choose which nonprofits they want their order proceeds to go towards
JavaScript
2
star
86

asekuro-contracts

Solidity smart contracts for Asekuro placement protocol
TypeScript
2
star
87

stow-example-policy

Example of a policy used for policy based permissions
JavaScript
2
star
88

web3studio-blackHoleSum

keeps summands secret while revealing only the sum
2
star
89

ArtFactory

Tokens for content
JavaScript
2
star
90

DaoWarsRevival

The DaoWars game that grew from the ConsenSys retreat '18 hackathon (aka ConsenSys Hacks)
JavaScript
2
star
91

web3studio-sidejam

SideJam is a series of projects designed to develop application-level examples, frameworks, components (and requirements driving protocol and R&D teams) that use the W3S narrative approach to prove the need for and ability to use the Mainnet as a way to make business safe without silos.
JavaScript
2
star
92

adhara-ui-boilerplate-elm

JavaScript
1
star
93

fluidex-scripts

Scripts for continuous deployment and continuous integration of Fluidex Exchange Platform.
Python
1
star
94

ImmutableEvidenceForm

Form to make evidence of a report immutable - uses drizzle build - starting template for related dapps
JavaScript
1
star
95

solidity-logo

Solidity Logo
1
star
96

blockapps-vm

JavaScript
1
star
97

stow-server

JavaScript
1
star
98

ujo.js

The Javascript SDK to interact with Ujo services
JavaScript
1
star
99

broker

Message Broker abstraction
Go
1
star
100

ipfs-challenge

Shell
1
star