Convert Figma logo to code with AI

argotorg logosolidity

Solidity, the Smart Contract Programming Language

25,216
6,212
25,216
634

Top Related Projects

OpenZeppelin Contracts is a library for secure smart contract development.

25,354

Solidity, the Smart Contract Programming Language

13,999

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.

Dapp, Seth, Hevm, and more

5,993

Static Analyzer for Solidity and Vyper

Quick Overview

Argotorg/solidity is a GitHub repository containing Solidity smart contracts and related tools. It appears to be a collection of various Solidity contracts, including examples and utilities, aimed at developers working with Ethereum and other compatible blockchain platforms.

Pros

  • Provides a variety of Solidity contract examples for learning and reference
  • Includes utility contracts and libraries that can be reused in other projects
  • Regularly updated with new contracts and improvements
  • Contains contracts for different use cases, such as tokens, governance, and DeFi

Cons

  • Limited documentation on how to use or integrate the contracts
  • Some contracts may not be thoroughly tested or audited
  • Lacks a clear project structure or organization
  • May require advanced knowledge of Solidity and blockchain development to fully utilize

Code Examples

Here are a few short code examples from the repository:

  1. Simple ERC20 Token Contract:
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract SimpleToken is ERC20 {
    constructor(uint256 initialSupply) ERC20("SimpleToken", "STK") {
        _mint(msg.sender, initialSupply);
    }
}

This code creates a basic ERC20 token using OpenZeppelin's ERC20 implementation.

  1. Governance Contract:
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/governance/Governor.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorSettings.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorCountingSimple.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorVotes.sol";

contract GovernanceContract is Governor, GovernorSettings, GovernorCountingSimple, GovernorVotes {
    constructor(IVotes _token)
        Governor("GovernanceContract")
        GovernorSettings(1 /* 1 block */, 45818 /* 1 week */, 0)
        GovernorVotes(_token)
    {}

    function quorum(uint256 blockNumber) public pure override returns (uint256) {
        return 1000e18;
    }
}

This contract implements a basic governance system using OpenZeppelin's Governor contracts.

  1. Staking Contract:
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

contract Staking is ReentrancyGuard {
    IERC20 public stakingToken;
    mapping(address => uint256) public stakedBalance;

    constructor(address _stakingToken) {
        stakingToken = IERC20(_stakingToken);
    }

    function stake(uint256 amount) external nonReentrant {
        require(amount > 0, "Cannot stake 0");
        stakingToken.transferFrom(msg.sender, address(this), amount);
        stakedBalance[msg.sender] += amount;
    }
}

This contract implements a basic staking mechanism for ERC20 tokens.

Getting Started

To use these contracts in your project:

  1. Install the required dependencies:

    npm install @openzeppelin/contracts
    
  2. Import the desired contract in your Solidity file:

    import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
    
  3. Inherit from the imported contract and customize as needed:

    contract MyToken is ERC20 {
        constructor() ERC20("MyToken", "MTK") {
            _mint(msg.sender, 1000000 * 10**decimals());
        }
    }
    
  4. Compile and deploy your contract using your preferred development environment (e.g., Truffle, Hardhat).

Competitor Comparisons

OpenZeppelin Contracts is a library for secure smart contract development.

Pros of openzeppelin-contracts

  • Extensive library of reusable smart contract components
  • Well-audited and battle-tested in production environments
  • Active community support and regular updates

Cons of openzeppelin-contracts

  • Larger codebase, potentially increasing gas costs
  • May include unnecessary features for simpler projects
  • Steeper learning curve for beginners

Code Comparison

openzeppelin-contracts:

contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;
    mapping(address => mapping(address => uint256)) private _allowances;
    uint256 private _totalSupply;
    string private _name;
    string private _symbol;

solidity:

contract Token {
    mapping(address => uint) public balanceOf;
    mapping(address => mapping(address => uint)) public allowance;
    uint public totalSupply;
    string public name;
    string public symbol;

The openzeppelin-contracts example showcases a more comprehensive implementation with additional features and inheritance, while the solidity example presents a simpler, more straightforward approach. openzeppelin-contracts offers enhanced security and standardization, but may be overkill for basic token implementations. solidity provides a leaner codebase, potentially reducing gas costs, but may lack some advanced features and security measures found in openzeppelin-contracts.

25,354

Solidity, the Smart Contract Programming Language

Error generating comparison

13,999

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.

Error generating comparison

Dapp, Seth, Hevm, and more

Pros of dapptools

  • Comprehensive suite of command-line tools for Ethereum development
  • Integrates well with other Ethereum development tools and frameworks
  • Provides a streamlined workflow for smart contract testing and deployment

Cons of dapptools

  • Steeper learning curve compared to Solidity's more straightforward approach
  • Less widely adopted in the Ethereum development community
  • May require additional setup and configuration

Code Comparison

Solidity (basic contract):

pragma solidity ^0.8.0;

contract SimpleStorage {
    uint256 private storedData;

    function set(uint256 x) public {
        storedData = x;
    }

    function get() public view returns (uint256) {
        return storedData;
    }
}

dapptools (using Seth for contract interaction):

# Deploy contract
export SETH_CHAIN=rinkeby
seth send --create out/SimpleStorage.bin 'SimpleStorage()'

# Set value
seth send $CONTRACT 'set(uint256)' 42

# Get value
seth call $CONTRACT 'get()'

While Solidity focuses on smart contract development, dapptools provides a broader set of tools for Ethereum development, including contract deployment and interaction. The code comparison illustrates the difference in approach, with Solidity showing the contract code itself and dapptools demonstrating how to interact with a deployed contract using command-line tools.

5,993

Static Analyzer for Solidity and Vyper

Pros of Slither

  • Specialized static analysis tool for Solidity, offering in-depth security checks
  • Actively maintained with frequent updates and community contributions
  • Provides a wide range of detectors for common vulnerabilities and best practices

Cons of Slither

  • Focused solely on analysis, not a full development environment like Solidity
  • May produce false positives, requiring manual verification of results
  • Steeper learning curve for interpreting and acting on analysis results

Code Comparison

Solidity (main language):

pragma solidity ^0.8.0;

contract SimpleStorage {
    uint256 private storedData;

    function set(uint256 x) public {
        storedData = x;
    }
}

Slither (analysis output):

INFO:Detectors:
SimpleStorage.set(uint256) (contracts/SimpleStorage.sol#5-7) uses a dangerous strict equality:
        - storedData = x
Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#dangerous-strict-equalities

Summary

Solidity is the primary language for Ethereum smart contract development, while Slither is a specialized static analysis tool for Solidity contracts. Solidity provides the core functionality for writing smart contracts, whereas Slither focuses on identifying potential vulnerabilities and enforcing best practices in existing Solidity code. While Solidity is essential for development, Slither serves as a valuable complementary tool for enhancing security and code quality in smart contract projects.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

The Solidity Contract-Oriented Programming Language

Matrix Chat Gitter Chat Solidity Forum X Follow Mastodon Follow

You can talk to us on Gitter and Matrix, tweet at us on X (previously Twitter) or create a new topic in the Solidity forum. Questions, feedback, and suggestions are welcome!

Solidity is a statically-typed, contract-oriented, high-level language for implementing smart contracts on the Ethereum platform.

For a good overview and starting point, please check out the official Solidity Language Portal.

Table of Contents

Background

Solidity is a statically-typed curly-braces programming language designed for developing smart contracts that run on the Ethereum Virtual Machine. Smart contracts are programs that are executed inside a peer-to-peer network where nobody has special authority over the execution, and thus they allow anyone to implement tokens of value, ownership, voting, and other kinds of logic.

When deploying contracts, you should use the latest released version of Solidity. This is because breaking changes, as well as new features and bug fixes, are introduced regularly. We currently use a 0.x version number to indicate this fast pace of change.

Build and Install

Instructions about how to build and install the Solidity compiler can be found in the Solidity documentation.

Example

A "Hello World" program in Solidity is of even less use than in other languages, but still:

// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.9.0;

contract HelloWorld {
    function helloWorld() external pure returns (string memory) {
        return "Hello, World!";
    }
}

To get started with Solidity, you can use Remix, which is a browser-based IDE. Here are some example contracts:

  1. Voting
  2. Blind Auction
  3. Safe remote purchase
  4. Micropayment Channel

Documentation

The Solidity documentation is hosted using Read the Docs.

Development

Solidity is still under development. Contributions are always welcome! Please follow the Developer's Guide if you want to help.

You can find our current feature and bug priorities for forthcoming releases in the projects section.

Maintainers

The Solidity programming language and compiler are open-source community projects governed by a core team. The core team is sponsored by the Ethereum Foundation.

License

Solidity is licensed under GNU General Public License v3.0.

Some third-party code has its own licensing terms.

Security

The security policy may be found here.