Skip to content

Instantly share code, notes, and snippets.

@DoZator
Created April 20, 2023 06:13
Show Gist options
  • Save DoZator/141b2680e4bae6716f31d58aa58cb45a to your computer and use it in GitHub Desktop.
Save DoZator/141b2680e4bae6716f31d58aa58cb45a to your computer and use it in GitHub Desktop.
Write an Ethereum smart contract
  • Install Truffle
    npm install -g truffle
  • Install Ganache

To install ganache globally as cli tool:

    npm install ganache --global

or install Ganache UI https://trufflesuite.com/ganache/

  • Creating a Truffle project
    truffle init new_project
  • Pick a contract name (for example Test)
    truffle create contract Test
  • To run test in Truffle
    truffle test
  • Compile the contracts
    truffle compile

Deploying the contract

  • To deploy our contract in a testing environment, we use ganache cli tool (or use Ganache UI)
    ganache

It will start a RPC server. After running ganache it will provide you and endpoint to connect with (for example http://127.0.0.1:8545)

  • To connect to this endpoint, modify the truffle-config.js
    networks: {
        ganacheLocal: {
            host: "127.0.0.1",
            port: 8545,
            network_id: "*"
        }
  • Deploy contract
    truffle deploy --network ganacheLocal

also you can use Ethereum Remix plugin for VS Code https://marketplace.visualstudio.com/items?itemName=RemixProject.ethereum-remix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment