LogoLogo
HomeBased Labs ResearchWhitepaper
  • 1: Introduction
    • BasedAI Mainnet Q&A Guide
    • Is Your AI Based?
    • BasedAI Ecosystem
    • The Role of Based CLI
  • 2: Installation
    • Minimum Requirements and Prerequisites
    • Installation Instructions
    • Verification of Installation & Troubleshooting
  • 3: Interaction with [Brains] and [Brainstore]
    • Section Overview
  • Using [basedcli brains]
    • [stem]: Retrieving Brain Information
    • [pow_memorize]: Registering Wallets with PoW
    • [memorize]: Associating Wallets with Brains
    • [parameters]: Viewing and Setting Brain Parameters
    • [list]: Viewing All Brains
  • Using [basedcli brainstore]
    • [list]: Accessing Community-Approved Brains
  • 4: Interaction with [Core] Network Operations
    • Section Overview
  • Using [basedcli core]
    • [list]: Listing Core Network Components
    • [weights]: Adjusting Influence on the Network
    • [get_weights]: Reviewing Current Distribution
    • [vote]: Participating in Governance
    • [gigabrains]: Viewing Current GigaBrains
    • [memorize]: Ensuring Network Recognition
    • [proposals]: Insight into Network Proposals
    • [delegate] & [undelegate]: Managing Staked Influence
  • 5: [Wallet] Functionality and Transactions
    • Section Overview
  • Using {basedcli wallet]
    • [list]: Viewing All Wallets
    • [overview]: Comprehensive Wallet Summary
    • [transfer]: Executing Token Transfers
    • [create]: Setting Up a New Wallet
    • [new_computekey] & [new_personalkey]: Generating Additional Keys
    • [regen_personalkey], [regen_personalkeypub], & [regen_computekey]: Regenerating Keys
  • 6: [Stake] Mechanics and [BrainOwner] Tools
    • Section Overview
  • Using [basedcli stake]
    • [show]: Show Stakes in Wallets
    • [add] & [remove]: Add or Remove Stakes
  • Using [basedcli brainowner]
    • [get]: Retrieve Brain Rules and Parameters
    • [set]: Adjusting Brain Parameters
  • 7: Commands Reference
    • Reference Table
  • 8: Implementing Smart Contracts in BasedAI
    • Introduction to the Ethereum Virtual Machine (EVM)
    • Prerequisites
    • Write a Smart Contract
    • Test & Deploy a Smart Contract
    • Tools and Technologies
    • Advanced Example: $PUMP Memecoin Launchpad
    • Advanced Example: AI Marketplace
    • Advanced Example: Brain #88 Access Token
  • 9: Forms
    • $BASED Faucet
    • Test Brain Ownership
    • Test Brain Tokens
Powered by GitBook
On this page
  1. 8: Implementing Smart Contracts in BasedAI

Test & Deploy a Smart Contract

Testing smart contracts is crucial to ensure they function correctly and securely. Follow these steps to test your smart contracts on the Cyan BasedAI Testnet.

Interacting with the Contract

  • Add the Contract to MetaMask: After deploying the contract, add its address to MetaMask to interact with it.

  • Verify Token Balance: Check the balance of your token in MetaMask.

  • Perform Transactions: Use MetaMask to perform transactions, such as transferring tokens or calling contract functions.

Testing with Remix

  • Deploy the Contract: Use Remix to deploy your contract to the BasedAI Testnet.

  • Execute Functions: Test the core functionalities (e.g., issueToken, deployAgent, addLiquidity, accessService) directly in Remix.

  • Check State Changes: Verify the contract's state changes and event emissions to ensure expected behavior.

Automated Testing

Automated testing provides a robust approach for verifying your contracts. Set up your environment with Truffle or Hardhat for automated testing.

Example Test Script with Hardhat:

const { expect } = require("chai");
const { ethers } = require("hardhat");

describe("AchievementToken", function () {
    it("Should deploy and issue tokens correctly", async function () {
        const [owner, addr1] = await ethers.getSigners();
        const AchievementToken = await ethers.getContractFactory("AchievementToken");
        const token = await AchievementToken.deploy();
        await token.deployed();

        await token.issueToken(addr1.address, 100, "Test Achievement");
        expect(await token.balanceOf(addr1.address)).to.equal(100);
    });
});

By following these guidelines, you can ensure that your smart contracts are robust and ready for deployment on the BasedAI Testnet.

PreviousWrite a Smart ContractNextTools and Technologies

Last updated 11 months ago