Pundi
Pundi AIPundi X
  • 🤖Pundi AI overview
  • 🈁Pundi AI Data Platform
    • Data stakeholders
    • Data Labelling
    • Pundi AI Data Platform (Alpha Testnet) - User Guide
    • FAQ
  • 🦾Pundi AIFX Omnilayer
    • Pundi AIFX
    • Installation Pundi AIFX
    • Setup Node
      • Full node with Binaries
      • Full node with Docker
      • Snapshot Guide
      • Node Monitoring Device
    • Validators
      • Validator Overview
      • Setting Up a Validator for Pundi AIFX
      • Validator Recovery
      • Validator FAQ
      • Validator Security Notice
      • Migration Best Practices
      • Transfer Validator Permissions
    • Delegators
      • Delegators FAQ
      • Delegator CLI Guide
      • Delegator Security Notice
    • Pundi AIFX Tutorials
      • Pundi AIFX CLI Commands
      • Cloud Setup
      • Testnet faucet
      • Ledger Integration for fxcored
      • Sentry Nodes
      • Account Migration Guide (CLI)
    • Upgrade Instructions
      • Cosmovisor Upgrade Guide v8.5.x
        • Cosmovisor Integration - Binaries
        • Cosmovisor Integration - Docker
      • Manual Upgrade Guide v8.5.x
        • Binaries - Upgrading Your Node
        • Docker - Upgrading Your Node
      • Upgrade Versions
        • v2.2.0 Upgrade Instructions
        • v3.1.0 Upgrade Instructions
        • v4.2.1 Upgrade Instructions
        • v5.0.0 Upgrade Instructions
      • Upgrade FAQ
    • Deploying on Pundi AIFX EVM
      • Products
      • MetaMask
        • Download and Install MetaMask
        • Add Network
        • Configure Custom Tokens
        • Create and Import Accounts
      • Connect Wallet to Dapps
        • Connect using MetaMask
        • Connect using Pundi Wallet (Wallet Connect)
      • With Remix
      • With Truffle
      • With Hardhat
      • Cross-Chain Bridges
        • Bridging Tokens from other networks
        • Pundi Gravity Bridge
    • DApps and Infra
      • Margin X Swap
      • Pundi Wallet
      • PundiScan
      • Baklava Space
      • Safe Multisig
      • PortfolioX
      • Token Factory
    • Developers
      • Pundi AIFX Network
      • Pundi AIFX Modules
      • Pundi AIFX JSON RPC
      • Pundi AIFX REST API
      • Web3 JSON RPC
        • JSON RPC Server
        • Namespaces
        • JSON RPC Methods
        • Events
      • Support Leap
      • Third Party Price Oracles
      • Contract Deployments
      • Pundi AIFX Cross Chain
        • sendToFx
        • f(x)Core
        • ibc
        • Target
      • Precompiled Contracts
        • CrossChain Precompiled
        • Staking-V2 Precompiled
      • Pundi AIFX SDKs
        • Python SDK
        • JavaScript SDK
      • Contract Monitoring
    • Pundi X Chain (under Pundi X)
      • Getting Started
        • Install Pundi X (PundiXChain)
        • Setup Node
          • Full node with Binaries
          • Full node with Docker
          • Snapshot Guide
          • Node Monitoring Device
          • Node Peers
      • Validators
        • Validator Overview
        • Setting Up a Validator for PundiXChain
        • Validator Recovery
        • Validator FAQ
        • Validator Security
        • Sentry Nodes
      • Delegators
        • Delegator FAQ
        • Delegator Overview
        • Delegator CLI Guide
      • Pundi X Tutorials
        • Pundi X CLI Guide
        • Ledger Integration for pundixd
        • Testnet Faucet
        • Cloud Setup
      • Upgrade Instructions
        • Cosmovisor Integration - Binaries
        • Cosmovisor Integration - Docker
        • Support keplr
      • Developers
        • Pundi X Network
        • Pundi X Protobuf
        • Pundi X gRPC & REST
        • Pundi X JSON RPC
        • Pundi X Cross Chain
          • ibc
  • 👛PURSE+
    • Purse Box
      • How many NFTs can I mint?
      • Minting (Etherscan)
      • Minting (Pursetoken.com)
    • PURSE+
      • Links
    • Bridging
      • BSC -> Ethereum
    • Protocols
      • LP Restaking Farms
        • How to Use Farms
        • Contract on BscScan
      • PURSE Staking
      • PURSE Staking Rewards
        • Campaigns
      • PURSE Retroactive Rewards
        • Campaigns
    • Contracts
      • Ethereum
      • Binance
      • Function X
    • IBC
      • PUNDIX Chain
    • PURSE Token
      • Background
      • ERC404 intro
      • Accounting of Balances
      • Minting PURSE NFT(s)
      • Transferring PURSE
      • Maintaining PURSE NFT(s)
      • NFTs in Queue
      • Token IDs
  • 🎡Pundi AI MM Agent
    • Why Market Making
    • Traditional MM vs. AMM
    • AI MM Agent: Bridging the Gap
    • Use Cases
    • Train & Launch (Step 1 & 2)
    • Flywheel (Step 3)
    • How the AI MM Agent Works in Detail
    • Why This is Powerful
  • 🛍️Pundi AI Data Marketplace (soon)
  • 🥇PUNDIAI Token Overview
    • Revenue generation flywheel
    • vePUNDIAI
      • how to bribe with vePUNDIAI
    • Protocol pool
  • Governance
    • Governance Proposal Information
      • EGF Info
      • EGF Grants Program
      • Application Template
      • Successful Grant Applicants
      • Launching an EGF Proposal
  • Links
Powered by GitBook
On this page
  • Setting up Remix IDE
  • Compile Smart Contract
  • ERC20 Tutorial Extended
  1. Pundi AIFX Omnilayer
  2. Deploying on Pundi AIFX EVM

With Remix

Remix IDE is an open source web and desktop application. It fosters a fast development cycle and has a rich set of plugins with intuitive GUIs.

PreviousConnect using Pundi Wallet (Wallet Connect)NextWith Truffle

Last updated 3 months ago

A Hello World style starter project. Deploys a smart contract with a message, and renders it in the front-end. You can change the message using the interactive panel!

This DAPP implements a "Hello World" style application that echoes a message passed to the contract to the front end. This tutorial is intended to be followed using the online IDE available at .

For more information on Remix and how to use it, you may find it in the .

Setting up

  • Remix IDE - an online IDE to develop smart contracts.

  • If you’re new to Remix, you’ll first need to activate two modules: Solidity Compiler and Deploy and Run Transactions (This should already be activated by default without you needing to search for it in the plugin manager).

  • Search for 'Solidity Compiler' in the plugin tab in Remix (this should be activated by default)

  • And activate the plugins (if they are not already activated)

  • The environment should be set to solidity by default

  • Copy/Paste the Smart contract below into the newly created file HelloWorld.sol

HelloWorld.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// Specifies that the source code is for a version
// of Solidity greater than 0.8.10

// A contract is a collliection of functions and data (its state)
// that resides at a specific address on the Ethereum blockchain.
contract HelloWorld {

    // The keyword "public" makes variables accessible from outside a contract
    // and creates a function that other contracts or SDKs can call to access the value
    string public message;

    // A special function only run during the creation of the contract
    constructor(string memory initMessage) {
        // Takes a string value and stores the value in the memory data storage area,
        // setting `message` to that value
        message = initMessage;
    }

    // A publicly accessible function that takes a string as a parameter
    // and updates `message`
    function update(string memory newMessage) public {
        message = newMessage;
    }
}

A contract in the sense of Solidity is a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain. The line string public message declares a public state variable called message of type string. You can think of it as a single slot in a database that you can query and alter by calling functions of the code that manages the database. The keyword public automatically generates a function that allows you to access the current value of the state variable from outside of the contract. Without this keyword, other contracts have no way to access the variable.

The string public message function is another public function that is similar to the constructor, taking a string as a parameter, and updating the message variable.

  • Copy/Paste the Smart contract below into the newly created file erc20.sol

  • Edit the string`` ``public`` ``name & string`` ``public`` ``symbol and replace it with your own name and symbol

Feel free to edit other parts of the contract. This is just a sample ERC20 contract for testing and might not have the necessary security checks in place.

erc20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Token {
    string public name = "Bluestitch";
    string public symbol = "WalaoBTC";
    uint256 public totalSupply;
    uint8 public decimals = 18;

    event Transfer(address indexed _from, address indexed _to, uint256 _value);

    event Approval(
        address indexed _owner,
        address indexed _spender,
        uint256 _value
    );

    mapping(address => uint256) public balanceOf;
    mapping(address => mapping(address => uint256)) public allowance;

    constructor() {
        balanceOf[msg.sender] = totalSupply;
    }

    function transfer(address _to, uint256 _value)
        public
        returns (bool success)
    {
        require(balanceOf[msg.sender] >= _value);
        balanceOf[msg.sender] -= _value;
        balanceOf[_to] += _value;
        emit Transfer(msg.sender, _to, _value);
        return true;
    }

    function approve(address _spender, uint256 _value)
        public
        returns (bool success)
    {
        allowance[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value);
        return true;
    }

    function transferFrom(
        address _from,
        address _to,
        uint256 _value
    ) public returns (bool success) {
        require(_value <= balanceOf[_from]);
        require(_value <= allowance[_from][msg.sender]);
        balanceOf[_from] -= _value;
        balanceOf[_to] += _value;
        allowance[_from][msg.sender] -= _value;
        emit Transfer(_from, _to, _value);
        return true;
    }

    function _mint(address account, uint256 amount) public {
        require(account != address(0), "ERC20: mint to the zero address");
        totalSupply += amount;
        balanceOf[account] += amount;
        emit Transfer(address(0), account, amount);
    }
}

A contract in the sense of Solidity is a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain. The line string public name & symbol declares public state variables called name & symbol of type string. The line uint256`` ``public`` ``totalSupply declares a uint256 variable that stores the amount of this particular token in existence. You can think of it as a single slot in a database that you can query and alter by calling functions of the code that manages the database. The keyword public automatically generates a function that allows you to access the current value of the state variable from outside of the contract. Without this keyword, other contracts have no way to access the variable.

Events are called Events because they are very good at signalling that an event has taken place. In blockchain terms, they’re cheap. They’re cheap to write in a contract in terms of deployment cost and gas cost when calling a function with an event, and they’re free to read. In short, they’re a very good way of broadcasting relevant information.

Compile Smart Contract

  • Select Compiler Version to 0.8.0

  • Now, Compile HelloWorld.sol /ERC20.sol

  • Now, we have to deploy our smart contract on Pundi AIFX Network. For that, we have to connect to web3, this can be done by using services like Metamask. We will be using Metamask. Please follow this tutorial to setup a Metamask Account.

  • Open Metamask, click the network dropdown and then click 'Add Network'. For more information on MetaMask and how to configure it to your network, you may check out this Metamask guide.

  • Put in a Network name (just an example):

fxtothemoon
  • In New RPC URL field you can add the URL:

https://testnet-fx-json-web3.functionx.io:8545
  • Enter the Chain ID:

90001
  • (Optional Field) Currency Symbol (just an example):

FX
  • (Optional Field) Block Explorer URL:

https://testnet-explorer.functionx.io/evm
  • Click Save

  • Copy your address from Metamask

  • Now, let's Deploy the Smart Contract to the Pundi AIFX Network

  • Select Injected Web3 in the Environment dropdown ensure you have selected the right contract too.

  • Accept the connection request by clicking Next in Metamask after choosing the account

  • Once Metamask is connected to Remix, the ‘Deploy’ transaction would generate another metamask popup that requires transaction confirmation.

  • Click the EDIT button (1st picture) and then the Edit suggested gas fee (2nd picture) before editing the Max priority fee and Max fee to 4000 Gwei then click SAVE.

  • Click Confirm

ERC20 Tutorial Extended

After deploying the ERC20.sol, your Remix should look something like the following:

Taking a look at the side panel in particular these sets of button functions where you can interact with the contract. By clicking on the drop down for those buttons that have a dropdown will require that you fill in those fields before clicking on the button to query/write the value of the function. For those buttons that do not have a field to fill in, you may just click on the button to read/write.

Orange buttons are writeable button functions. Blue buttons are readable button functions

Now with our custom token added, we are all ready to mint some tokens and interact with the ERC20 contract.

Clicking into the _mint (example) dropdown, you will be shown a few fields:

The fields are pretty self explanatory. Amount has to be of the type unit256 (unsigned integer), while Account has to be of the address (0x) type. Input your address and the amount you would like to mint. Do remember to add 18 0s behind. The amount value here is expressed in Wei. So if you want to mint 100 of your tokens, the field should be 100000000000000000000.

Now lets go through the rest of the buttons one by one:

totalSupply() → uint256

Returns the amount of tokens in existence.

symbol() → string

Returns the symbol of the token, usually a shorter version of the name.

name() → string

Returns the name of the token.

decimals() → uint8

Returns the number of decimals used to get its user representation. For example, if decimals equals 2, a balance of 505 tokens should be displayed to a user as 5,05 (505 / 10 ** 2).

Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei.

balanceOf(address account) → uint256

Returns the amount of tokens owned by account.

Do not forget to fill in the account field with the 0x address you would like to query.

allowance(address owner, address spender) → uint256
transferFrom(address sender, address recipient, uint256 amount) → bool

Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller’s allowance.

Returns a boolean value indicating whether the operation succeeded.

transfer(address recipient, uint256 amount) → bool

Moves amount tokens from the caller’s account to recipient.

Returns a boolean value indicating whether the operation succeeded.

approve(address spender, uint256 amount) → bool

Sets amount as the allowance of spender over the caller’s tokens.

Returns a boolean value indicating whether the operation succeeded.

_mint(address account, uint256 amount)

Creates amount tokens and assigns them to account, increasing the total supply.

Requirements

  • to cannot be the zero address.

Go to File Explorers, To create a new file , Name it HelloWorld.sol

The first line, pragma solidity ^0.8.0 specifies that the source code is for a Solidity version greater than 0.8.0. are common instructions for compilers about how to treat the source code (e.g., pragma once).

The is a special function run during the creation of the contract and cannot be called afterward. In this case, it takes a string value initMessage, stores the value in the data storage area, and sets message to that value.

Go to File Explorers, To create a new file , Name it erc20.sol

The first line, pragma solidity ^0.8.0 specifies that the source code is for a Solidity version greater than 0.8.0. are common instructions for compilers about how to treat the source code (e.g., pragma once).

For more information on the ERC20 standard and the various variables, you may refer .

Go to Solidity Compiler

After Successful Compilation, it will show

Head over to and request test FX - you will need this to pay for gas on Pundi AIFX. After inputting your wallet address in, select the option '100 (fxCore) FX / 24h'.

Congratulations! You have successfully deployed HelloWorld/ERC20 Smart Contract. Now you can interact with the Smart Contract. Check the deployment status .

Copy the deployed contract address and input it in Metamask. And step through with adding the custom token.

Hitting will result in a Metamask pop-up. Remember to edit the gas fields to reflect 4000 GasPrice similar to what you did before and voila, you will have minted some of your own tokens.

Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through . This is zero by default.

This value changes when or are called.

Emits a event.

Emits a event.

Emits an event.

Emits a event with from set to the zero address.

🦾
Pragmas
constructor
memory
Pragmas
here
faucet
here
transferFrom
approve
transferFrom
Transfer
Transfer
Approval
transfer
Remix IDE
Remix Documentation
Remix IDE
Metamask Network Configuration
Injected Web3
Adjusting Gas Price
Interacting with Deployed Contract
ERC20 Remix Page
Remix Button Functions