Acala Wiki
LearnBuildMaintain
  • Acala & Karura Wiki
  • Acala 2.0
    • Overview
    • Execution Roadmap
    • aUSD SEED (aSEED)
      • aSEED Integration Guide
    • ACA
      • ACA/KAR Staking
    • Universal Asset Hub (UAH)
    • Euphrates DApp
  • Learn
    • Acala Introduction
      • Acala Dollar
      • AcalaSwap
      • Homa Liquid Staking
      • Redenomination of ACA
    • Trilogy Networks
    • Flexible Fees
      • How to change default fee token
    • Governance Overivew
      • Participate in Democracy
      • How to Verify a Runtime Upgrade
      • How to Verify Referendum Proposal
    • Treasury
    • Acala EVM+
      • Why Acala EVM+
      • Existing Solutions
      • Acala EVM+
        • Composable DeFi Stack
        • Flexible Fees
        • EVM Account
        • On-chain Scheduler
        • Queryable & Lightweight
        • Upgradable Contracts
        • Compatible Toolings
        • No Dust Account
      • How does it work?
  • Get started
    • Acala Network
      • Acala Launch Phases
      • Wallet & Account
        • Account Generation
          • Polkadot{.js} Browser Extension
          • Polkawallet Mobile App
          • Ledger Hardware Wallet
        • Exchange Withdraw/Deposit
        • Balance Type and Vesting
        • Check Address for Different Chains
      • Acala's DOT Bridge
      • Acala Assets
      • Governance
      • Acala Web Apps
      • Acala Mobile
    • Karura Network
      • Karura Launch Phases
      • Check Distribution
      • Wallets & Account
        • Account Generation
          • Polkadot{.js} Browser Extension
          • Polkawallet Mobile App
          • Ledger Hardware Wallet
        • Exchange Withdraw/Deposit
        • Balance Type & Vesting
        • Check Address for Different Chains
      • Inter Kusama Transfer
      • Karura Assets
      • Karura Web Apps
      • Governance
      • Transaction Fees
    • Mandala Testnet
  • Integrate
    • Acala Network
      • Protocol Info
      • Token Transfer
      • Node Interaction
      • Full Node
      • Collator
    • Karura Network
      • Protocol Info
      • Token Transfer
      • Node Interaction
      • Full Node
      • Collator
  • Build
    • EVM+ documentation
    • SDKs
      • Acala Stablecoin
      • Homa Liquid Staking
      • AcalaSwap
      • Homa Staking
    • Guides
      • Node Interaction
      • Transaction Construction
    • Build DApps
      • Deploy Ecosystem Modules
      • Composable Chains
        • Open HRMP Channel
        • Bridge Tokens
        • Cross-chain Listing
      • Open-Web3-Stack & ORML
      • Smart Contracts
        • Acala EVM Overview
        • Get Started
          • Connect to a Node
            • Use MetaMask with EVM+
          • Setup EVM Account
          • Polkadot Explorer
          • EVM Playground
          • Use Remix
          • Use Waffle
          • Use Hardhat
          • Deploy Contracts
        • Advanced
          • Use Native & Cross-chain Tokens
          • Use On-chain Scheduler
            • Tutorial
          • Use Oracle Feeds
          • Upcoming Features
        • Acala EVM Hacker Guide
          • Try Acala DApp
    • Tools
    • Indexers
      • SubQuery
    • Miscellaneous
      • Runtime Events
      • Modules
    • Cross Chain DeFi
  • Ecosystem
    • General Info
    • Alliance
    • Community
    • Contribution & Rewards
      • Acala Old Friend NFT
    • Ecosystem
    • Media Kits
    • Ledger Generic App Migration
  • Crowdloans
    • What are crowdloans
    • Acala Crowdloan
      • Crowdloan Event
      • Crowdloan Rewards
      • Claim ACA
      • How to Crowdloan
      • FAQ
      • Acala Quests
        • Attaching Polkawallet to Polkadot.js Extension
      • DOT Address
        • Creating a New DOT Account
        • Becoming a DOT Holder
        • Unstaking Your DOT
          • Unstaking Your DOT Tokens on Polkadot.{js} Extension
          • Unstaking Your DOT Tokens on Polkawallet
    • Karura Crowdloan
      • Crowdloan Event
      • Crowdloan Rewards
      • Claim KAR
      • How to Crowdloan
      • FAQ
      • KSM Address
        • Creating a New KSM Account
        • Check KSM Address
        • Unstaking Your KSM
          • Unstaking Your KSM Tokens on Polkawallet
          • Unstaking Your KSM Tokens on Polkadot.{js} Extension
      • Finding Tokens and NFTs
  • Misc
    • aUSD Incident
    • Contributing
    • Glossary
Powered by GitBook
On this page
  • Compile Solidity Contract using Waffle Comment
  • 1. Check Prerequisites
  • 2. Using Waffle With Our Examples
  • 3. Using Waffle from Scratch (optional)
  • 4. Compile the Smart Contract
  • 5. Get the ABI file

Was this helpful?

Edit on GitHub
  1. Build
  2. Build DApps
  3. Smart Contracts
  4. Get Started

Use Waffle

PreviousUse RemixNextUse Hardhat

Last updated 4 years ago

Was this helpful?

There are multiple tools you can use to develop and compile Solidity contracts, we'd present two here as options

  • online web app Remix

  • Solidity development and testing framework Waffle

Compile Solidity Contract using Waffle Comment

Note: you can skip this section if you compiled the smart contract with Remix.

This guide walks through the process of deploying a Solidity-based smart contract to Acala using . Waffle is one of the most commonly used smart contract development frameworks for Ethereum.

1. Check Prerequisites

First, we need to install Node.js (we use v15.x in this example) and the npm package manager. For installation follow guides in the official documentation for your operating system:

We can verify that everything installed correctly by querying the version for each package:

node -v
npm -v

Install yarn package manager:

npm install --global yarn

Check if it's installed correctly:

yarn -v

2. Using Waffle With Our Examples

Simply clone the repository and install the dependencies.

git clone https://github.com/AcalaNetwork/evm-examples
cd evm-examples/erc20

yarn install

3. Using Waffle from Scratch (optional)

Alternatively, you can install each library separately as the following:

Create a project folder smart-contract-waffle

mkdir smart-contract-waffle
cd smart-contract-waffle

Initiate package manager

yarn init -y

Install all following dependencies

yarn add --dev @openzeppelin/contracts@3.3.0 ethereum-waffle@3.2.1

Note: it's recommended to install dependencies with exact versions as specified to avoid breaking changes.

Then create a waffle settings file

touch waffle.json

Paste the following in the waffle.json file

 {
    "compilerType": "solcjs",
    "compilerVersion": "0.6.2",
    "sourceDirectory": "./contracts",
    "outputDirectory": "./build"
  }

This sets up the solidity compiler with version 0.6.2, compiles contracts from the ./contracts folder, and saves the bytecode output and ABI files to ./build folder.

Now create the ./contracts folder, and add the BasicToken.sol contract.

mkdir contracts
touch contracts/BasicToken.sol

Paste the following content into the BasicToken.sol file and save.

pragma solidity ^0.6.0;

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

// Example class - a mock class using delivering from ERC20
contract BasicToken is ERC20 {
    constructor(uint256 initialBalance) public ERC20("Basic", "BSC") {
        _mint(msg.sender, initialBalance);
    }
}

4. Compile the Smart Contract

Now compile the contract into ABI and bytecode. Run the following in the terminal

yarn waffle

5. Get the ABI file

Waffle will then generate the output file ./build/BasicToken.json into the ./build folder.

Note: this file should be the same as the one created with Remix.

We've made it easy by collecting all required dependencies in the repo.

Waffle also provides a full suite of testing utilities, check out their documentation and code samples .

Waffle
install NodeJS
AcalaNetwork/evm-examples
here