1. Home
  2. Docs
  3. Nexi Docs
  4. Build on the chain
  5. Building information

Building information

1. Setting Up the Development Environment

Prerequisites:

  • Install MetaMask or another web3 wallet that supports Nexi chain.
  • Have some Nexi testnet tokens for deploying contracts (if testing).

Connecting to the Nexi Chain in MetaMask:

  1. Open MetaMask and click on the network dropdown.
  2. Click “Add Network” and fill in the following details:

2. Writing the Smart Contract in Remix

  1. Go to Remix IDE.
  2. Create a new file (e.g., MyContract.sol).
  3. Write your Solidity code. Below is a simple example of an ERC20 token contract:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

contract MyToken is ERC20 {
constructor() ERC20("MyToken", "MTK") {
_mint(msg.sender, 1000000 * 10 ** decimals());
}
}

3. Compiling the Contract

  1. In Remix, go to the “Solidity Compiler” tab (left sidebar).
  2. Select the Solidity version that matches your contract (e.g., 0.8.0).
  3. Click “Compile MyContract.sol”.

4. Deploying the Contract on Nexi Chain

  1. Deploy with MetaMask:
    • Go to the “Deploy & Run Transactions” tab in Remix.
    • Set the “Environment” to “Injected Web3” (MetaMask).
    • Ensure MetaMask is connected to the Nexi chain.
    • Select your contract from the dropdown menu.
    • Click “Deploy” and confirm the transaction in MetaMask.
  2. Contract Verification (Optional):
    • After deployment, note the contract address.
    • Use Nexi’s block explorer for contract verification if available.

5. Interacting with the Contract

  • Once deployed, you can interact with your contract directly from Remix using the interface provided under the “Deployed Contracts” section.
  • Use functions like transfer, balanceOf, or any other functions defined in your smart contract.

6. Testing and Debugging

  • Testing: Use Remix’s built-in testing environment to test contract functions.
  • Debugging: Utilize Remix’s debugger tool if any issues arise during contract interaction.

7. Best Practices and Security Considerations

  • Security Audits: Before deploying on the mainnet, consider getting your contracts audited for security vulnerabilities.
  • Gas Optimization: Optimize contract functions to minimize gas costs.
  • Upgradability: If needed, consider implementing proxy patterns for contract upgradability.