Nanoscale Parts Manufacturing

    TypeScript icon, indicating that this package has built-in type declarations

    0.0.21 • Public • Published


    The Solang Compiler compiles Solidity contracts to native Solana BPF programs.

    This TypeScript library, inspired by Ethers.js, can deploy and interact with Solidity contracts on Solana.


    • Compile, load, and deploy Solidity contracts
    • Redeploy and reuse existing contract programs
    • Call contract functions to read and write data
    • Subscribe to contract events and program logs

    Quick Setup

    This is a short guide to deploying and interacting with the standard ERC20 Solidity contract on Solana.

    1. Install Docker and Node.js (version 14 or higher).

    2. Clone the repositoy.

    git clone
    cd solana-solidity.js
    1. Pull the Docker images to compile and deploy your contracts:
    yarn docker
    1. Start the Solana test validator:
    yarn validator
    1. In a new terminal window, initialize a project:
    mkdir -p project/contracts project/build
    cd project
    curl -o contracts/ERC20.sol \
    1. Compile the Solidity contract:
    docker run --rm -it -v $PWD:/project \
           -o /project/build --target solana -v /project/contracts/ERC20.sol

    This outputs ERC20.abi and files to the build directory.

    1. Install the library:
    yarn add @solana/solidity
    # OR
    npm install @solana/solidity
    1. Create a script file to run:
    touch erc20.js
    1. Paste this code in the file and save it:
    const { Connection, LAMPORTS_PER_SOL, Keypair } = require('@solana/web3.js');
    const { Contract, publicKeyToHex } = require('@solana/solidity');
    const { readFileSync } = require('fs');
    const ERC20_ABI = JSON.parse(readFileSync('./build/ERC20.abi', 'utf8'));
    const BUNDLE_SO = readFileSync('./build/');
    (async function () {
        console.log('Connecting to your local Solana node ...');
        const connection = new Connection('http://localhost:8899', 'confirmed');
        const payer = Keypair.generate();
        console.log('Airdropping SOL to a new wallet ...');
        const signature = await connection.requestAirdrop(payer.publicKey, 10 * LAMPORTS_PER_SOL);
        await connection.confirmTransaction(signature, 'confirmed');
        const address = publicKeyToHex(payer.publicKey);
        const program = Keypair.generate();
        const storage = Keypair.generate();
        const contract = new Contract(
        console.log('Deploying the Solang-compiled ERC20 program ...');
        await contract.load(program, BUNDLE_SO);
        console.log('Program deployment finished, deploying the ERC20 contract ...');
        await contract.deploy(
            ['Solana', 'SOL', '1000000000000000000'],
            4096 * 8
        console.log('Contract deployment finished, invoking some contract functions ...');
        const symbol = await contract.symbol();
        const balance = await contract.balanceOf(address);
        console.log(`ERC20 contract for ${symbol} deployed!`);
        console.log(`Your wallet at ${address} has a balance of ${balance} tokens.`);
        contract.addEventListener(function (event) {
            console.log(`${} event emitted!`);
            console.log(`${event.args[0]} sent ${event.args[2]} tokens to ${event.args[1]}`);
        console.log('Sending tokens will emit a "Transfer" event ...');
        const recipient = Keypair.generate();
        await contract.transfer(publicKeyToHex(recipient.publicKey), '1000000000000000000');
    1. Run the script to deploy and interact with your contract on Solana!
    node erc20.js

    Build from source

    1. Clone the project:
    git clone
    cd solana-solidity.js
    1. Install the dependencies:
    yarn install
    1. Compile the library from TypeScript to JavaScript:
    yarn build
    1. Pull the Docker images to build and run the tests:
    yarn docker
    1. Start the test validator:
    yarn validator
    1. In another terminal window, build and run the tests:
    yarn build:test
    yarn test




    npm i @solana/solidity

    DownloadsWeekly Downloads






    Unpacked Size

    111 kB

    Total Files


    Last publish


    • _chido
    • steveluscher
    • sebastianbor
    • seanyoung
    • mvines
    • jstarry
    • danpaul000
    • jack-solana
    • tyera
    • joncinque
    • bartosz-lipinski
    • ryoqun
    • trent-solana
    • jordansexton