JavaScript Solidity

Open-source JavaScript projects categorized as Solidity

Top 23 JavaScript Solidity Projects

  • openzeppelin-contracts

    OpenZeppelin Contracts is a library for secure smart contract development.

    Project mention: A look into formal verification of smart contracts using Certora | | 2022-12-02

    Let's grab some examples from OpenZeppelin's TimelockController spec. In a Timelock, operations can have different states. We can write a rule that checks, for instance, that calling execute is the only way for moving an operation from ready to done state.

  • ethereumbook

    Mastering Ethereum, by Andreas M. Antonopoulos, Gavin Wood

    Project mention: How can I learn Blockchain development? | | 2022-11-24

    mastering ethereum book is one of the best book for beginner. You can read it on github github link Another best resource is Ethereum foundation doc Eth doc link

  • InfluxDB

    Build time-series-based applications quickly and at scale.. InfluxDB is the Time Series Data Platform where developers build real-time applications for analytics, IoT and cloud-native services in less time with less code.

  • eattheblocks

    Source code for Eat The Blocks, a screencast for Ethereum Dapp Developers

    Project mention: How to make your own Cryptocurrency very easily | | 2022-10-24
  • project_web3.0

    This is a code repository for the corresponding video tutorial. In this video, we're going to build a Web 3.0 React Solidity Blockchain Application

    Project mention: Krypt – Web 3.0 Blockchain Application | | 2022-01-31
  • merkletreejs

    🌱 Construct Merkle Trees and verify proofs in JavaScript.

    Project mention: Using a Merkle tree for validating off-chain data on IPFS | | 2022-01-31


  • Ethlint

    (Formerly Solium) Code quality & Security Linter for Solidity

    Project mention: Introducción a los Contratos Inteligentes con Solidity | | 2022-07-14

    pragma solidity ^0.5.10; // Imports symbols from other files into the current contract. // In this case, a series of helper contracts from OpenZeppelin. // Learn more: import "../node_modules/@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "../node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "../node_modules/@openzeppelin/contracts/introspection/ERC165.sol"; import "../node_modules/@openzeppelin/contracts/math/SafeMath.sol"; // The `is` keyword is used to inherit functions and keywords from external contracts. // In this case, `CryptoPizza` inherits from the `IERC721` and `ERC165` contracts. // Learn more: contract CryptoPizza is IERC721, ERC165 { // Uses OpenZeppelin's SafeMath library to perform arithmetic operations safely. // Learn more: using SafeMath for uint256; // Constant state variables in Solidity are similar to other languages // but you must assign from an expression which is constant at compile time. // Learn more: uint256 constant dnaDigits = 10; uint256 constant dnaModulus = 10 ** dnaDigits; bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Struct types let you define your own type // Learn more: struct Pizza { string name; uint256 dna; } // Creates an empty array of Pizza structs Pizza[] public pizzas; // Mapping from pizza ID to its owner's address mapping(uint256 => address) public pizzaToOwner; // Mapping from owner's address to number of owned token mapping(address => uint256) public ownerPizzaCount; // Mapping from token ID to approved address mapping(uint256 => address) pizzaApprovals; // You can nest mappings, this example maps owner to operator approvals mapping(address => mapping(address => bool)) private operatorApprovals; // Internal function to create a random Pizza from string (name) and DNA function _createPizza(string memory _name, uint256 _dna) // The `internal` keyword means this function is only visible // within this contract and contracts that derive this contract // Learn more: internal // `isUnique` is a function modifier that checks if the pizza already exists // Learn more: isUnique(_name, _dna) { // Adds Pizza to array of Pizzas and get id uint256 id = SafeMath.sub(pizzas.push(Pizza(_name, _dna)), 1); // Checks that Pizza owner is the same as current user // Learn more: // note that address(0) is the zero address, // indicating that pizza[id] is not yet allocated to a particular user. assert(pizzaToOwner[id] == address(0)); // Maps the Pizza to the owner pizzaToOwner[id] = msg.sender; ownerPizzaCount[msg.sender] = SafeMath.add( ownerPizzaCount[msg.sender], 1 ); } // Creates a random Pizza from string (name) function createRandomPizza(string memory _name) public { uint256 randDna = generateRandomDna(_name, msg.sender); _createPizza(_name, randDna); } // Generates random DNA from string (name) and address of the owner (creator) function generateRandomDna(string memory _str, address _owner) public // Functions marked as `pure` promise not to read from or modify the state // Learn more: pure returns (uint256) { // Generates random uint from string (name) + address (owner) uint256 rand = uint256(keccak256(abi.encodePacked(_str))) + uint256(_owner); rand = rand % dnaModulus; return rand; } // Returns array of Pizzas found by owner function getPizzasByOwner(address _owner) public // Functions marked as `view` promise not to modify state // Learn more: view returns (uint256[] memory) { // Uses the `memory` storage location to store values only for the // lifecycle of this function call. // Learn more: uint256[] memory result = new uint256[](ownerPizzaCount[_owner]); uint256 counter = 0; for (uint256 i = 0; i < pizzas.length; i++) { if (pizzaToOwner[i] == _owner) { result[counter] = i; counter++; } } return result; } // Transfers Pizza and ownership to other address function transferFrom(address _from, address _to, uint256 _pizzaId) public { require(_from != address(0) && _to != address(0), "Invalid address."); require(_exists(_pizzaId), "Pizza does not exist."); require(_from != _to, "Cannot transfer to the same address."); require(_isApprovedOrOwner(msg.sender, _pizzaId), "Address is not approved."); ownerPizzaCount[_to] = SafeMath.add(ownerPizzaCount[_to], 1); ownerPizzaCount[_from] = SafeMath.sub(ownerPizzaCount[_from], 1); pizzaToOwner[_pizzaId] = _to; // Emits event defined in the imported IERC721 contract emit Transfer(_from, _to, _pizzaId); _clearApproval(_to, _pizzaId); } /** * Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; * otherwise, the transfer is reverted. */ function safeTransferFrom(address from, address to, uint256 pizzaId) public { // solium-disable-next-line arg-overflow this.safeTransferFrom(from, to, pizzaId, ""); } /** * Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; * otherwise, the transfer is reverted. */ function safeTransferFrom( address from, address to, uint256 pizzaId, bytes memory _data ) public { this.transferFrom(from, to, pizzaId); require(_checkOnERC721Received(from, to, pizzaId, _data), "Must implement onERC721Received."); } /** * Internal function to invoke `onERC721Received` on a target address * The call is not executed if the target address is not a contract */ function _checkOnERC721Received( address from, address to, uint256 pizzaId, bytes memory _data ) internal returns (bool) { if (!isContract(to)) { return true; } bytes4 retval = IERC721Receiver(to).onERC721Received( msg.sender, from, pizzaId, _data ); return (retval == _ERC721_RECEIVED); } // Burns a Pizza - destroys Token completely // The `external` function modifier means this function is // part of the contract interface and other contracts can call it function burn(uint256 _pizzaId) external { require(msg.sender != address(0), "Invalid address."); require(_exists(_pizzaId), "Pizza does not exist."); require(_isApprovedOrOwner(msg.sender, _pizzaId), "Address is not approved."); ownerPizzaCount[msg.sender] = SafeMath.sub( ownerPizzaCount[msg.sender], 1 ); pizzaToOwner[_pizzaId] = address(0); } // Returns count of Pizzas by address function balanceOf(address _owner) public view returns (uint256 _balance) { return ownerPizzaCount[_owner]; } // Returns owner of the Pizza found by id function ownerOf(uint256 _pizzaId) public view returns (address _owner) { address owner = pizzaToOwner[_pizzaId]; require(owner != address(0), "Invalid Pizza ID."); return owner; } // Approves other address to transfer ownership of Pizza function approve(address _to, uint256 _pizzaId) public { require(msg.sender == pizzaToOwner[_pizzaId], "Must be the Pizza owner."); pizzaApprovals[_pizzaId] = _to; emit Approval(msg.sender, _to, _pizzaId); } // Returns approved address for specific Pizza function getApproved(uint256 _pizzaId) public view returns (address operator) { require(_exists(_pizzaId), "Pizza does not exist."); return pizzaApprovals[_pizzaId]; } /** * Private function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token */ function _clearApproval(address owner, uint256 _pizzaId) private { require(pizzaToOwner[_pizzaId] == owner, "Must be pizza owner."); require(_exists(_pizzaId), "Pizza does not exist."); if (pizzaApprovals[_pizzaId] != address(0)) { pizzaApprovals[_pizzaId] = address(0); } } /* * Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf */ function setApprovalForAll(address to, bool approved) public { require(to != msg.sender, "Cannot approve own address"); operatorApprovals[msg.sender][to] = approved; emit ApprovalForAll(msg.sender, to, approved); } // Tells whether an operator is approved by a given owner function isApprovedForAll(address owner, address operator) public view returns (bool) { return operatorApprovals[owner][operator]; } // Takes ownership of Pizza - only for approved users function takeOwnership(uint256 _pizzaId) public { require(_isApprovedOrOwner(msg.sender, _pizzaId), "Address is not approved."); address owner = this.ownerOf(_pizzaId); this.transferFrom(owner, msg.sender, _pizzaId); } // Checks if Pizza exists function _exists(uint256 pizzaId) internal view returns (bool) { address owner = pizzaToOwner[pizzaId]; return owner != address(0); } // Checks if address is owner or is approved to transfer Pizza function _isApprovedOrOwner(address spender, uint256 pizzaId) internal view returns (bool) { address owner = pizzaToOwner[pizzaId]; // Disable solium check because of // // solium-disable-next-line operator-whitespace return (spender == owner || this.getApproved(pizzaId) == spender || this.isApprovedForAll(owner, spender)); } // Check if Pizza is unique and doesn't exist yet modifier isUnique(string memory _name, uint256 _dna) { bool result = true; for (uint256 i = 0; i < pizzas.length; i++) { if ( keccak256(abi.encodePacked(pizzas[i].name)) == keccak256(abi.encodePacked(_name)) && pizzas[i].dna == _dna ) { result = false; } } require(result, "Pizza with such name already exists."); _; } // Returns whether the target address is a contract function isContract(address account) internal view returns (bool) { uint256 size; // Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // See // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. // solium-disable-next-line security/no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } }

  • solhint

    Solhint is an open source project created by Its goal is to provide a linting utility for Solidity code.

    Project mention: An Overview of the Tools for Developing on Flow & Cadence | | 2022-10-18

    The same is true for Solhint, a linter tool for Solidity. Again, Solidity’s static type system is very rudimentary and doesn’t prevent many errors while using the language. Solhint comes to aid here and provides tips on top of the type system to avoid misuse.

  • Sonar

    Write Clean JavaScript Code. Always.. Sonar helps you commit clean code every time. With over 300 unique rules to find JavaScript bugs, code smells & vulnerabilities, Sonar finds the issues while you focus on the work.

  • eth-crypto

    Cryptographic javascript-functions for ethereum and tutorials to use them with web3js and solidity

  • react-box

    Truffle, Webpack and React boilerplate.

    Project mention: Use the Truffle Suite for Easy Web3 - and Earn your Proof of Contribution POAP | | 2022-11-10

    Truffle Boxes are boilerplates or starters that set your project in a specific direction. They consist of code to get you going quickly, so you don’t have to reinvent the wheel every time. Some useful boxes include the nft-box, optimism, arbitrum, react, and polygon. You can even create your Truffle Boxes!

  • solidity-shell

    An interactive Solidity Shell

  • aragon-apps

    (Aragon 1) Aragon apps developed by Aragon Core Devs (smart contracts + webapps)

    Project mention: List of smart contracts to strengthen your Auditing skills | | 2022-10-03 21 Aragon Finance

  • truffle-flattener

    Truffle Flattener concats solidity files from Truffle and Buidler projects with all of their dependencies

  • eth-sdk

    Type-safe, lightweight SDKs for Ethereum smart contracts

    Project mention: Provide contract natspect together with ABIs | | 2022-01-13

    Discussion on Github with krzkaczor on the eth-sdk / typechain project:

  • solidity-flattener

    Utility to combine Solidity project to a flat file (by poanetwork)

  • wyvern-ethereum

    Project Wyvern Ethereum Smart Contracts

    Project mention: OpenSea / Wyvern Protocol Notes (Draft - Unfinished) | | 2022-10-05

    This is the Wyvern smart contract that governs that exchange process:

  • abi-to-sol

    Generate Solidity interface from ABI JSON

    Project mention: How do I import a 3rd party contract ABI in solidity/truffle | | 2022-05-24

    Under the hood, truffle uses

  • hashed-timelock-contract-ethereum

    Hashed Timelock Contracts for ETH, ERC20 and ERC721 on Ethereum

  • SoliditySamples

    Solidity Smart Contracts Samples

    Project mention: New to ETH need Guidance | | 2022-03-27
  • bepro-js

    The repository contains a comprehensive documentation of the ecosystem as a javascript framework. If you are new to BEPRO, you might want to check out the Website Overview or our public "Start Building" Page.

  • defisaver-v3-contracts

    All the contracts related to the Defi Saver ecosystem

    Project mention: Anyone know where I can collateralize my $rETH? | | 2022-11-20

    For anyone interested we'll have all for rETH Maker Vaults supported right away at and please feel free to ask away anything about rETH in Maker! (I'm a team member at defi saver, one of the oldest Maker integrators/frontends)

  • ERC20-Staking-Machine

    Dapp that implements a "fake-stake" mechanism on any ERC20 token

  • aragon-court

    🧿 A subjective oracle secured by cryptoeconomics

    Project mention: Can I leave a comment when I vote? | | 2022-06-08

    Right but I'm looking at different use cases not just purely for voting aka going to the poll. Below is an example taken from ->

  • contracts

    StakeWise smart contracts. (by stakewise)

    Project mention: Rocket Pool is at capacity - What is the second best option of pool staking? | | 2022-05-04
  • Zigi

    Close all those tabs. Zigi will handle your updates.. Zigi monitors Jira and GitHub updates, pings you when PRs need approval and lets you take fast actions - all directly from Slack! Plus it reduces cycle time by up to 75%.

NOTE: The open source projects on this list are ordered by number of github stars. The number of mentions indicates repo mentiontions in the last 12 Months or since we started tracking (Dec 2020). The latest post mention was on 2022-12-02.

JavaScript Solidity related posts


What are some of the best open-source Solidity projects in JavaScript? This list will help you:

Project Stars
1 openzeppelin-contracts 20,702
2 ethereumbook 16,827
3 eattheblocks 3,758
4 project_web3.0 3,144
5 merkletreejs 892
6 Ethlint 866
7 solhint 814
8 eth-crypto 760
9 react-box 717
10 solidity-shell 469
11 aragon-apps 378
12 truffle-flattener 362
13 eth-sdk 358
14 solidity-flattener 251
15 wyvern-ethereum 218
16 abi-to-sol 214
17 hashed-timelock-contract-ethereum 188
18 SoliditySamples 179
19 bepro-js 161
20 defisaver-v3-contracts 138
21 ERC20-Staking-Machine 120
22 aragon-court 113
23 contracts 103
Truly a developer’s best friend
Scout APM is great for developers who want to find and fix performance issues in their applications. With Scout, we'll take care of the bugs so you can focus on building great things 🚀.