TokenScript Agent
Overview
TokenScript Agent empowers users to create, deploy, and manage smart contracts seamlessly by leveraging Web3GPT AI-driven code generation. Users can simply describe their requirements, and TokenScript Agent will produce the Solidity code, suggest edits, handle deployment and create a TokenScript for the deployed contract.
Features
- Web3GPT AI-Powered Smart Contract Generation: Converts user descriptions into ready-to-compile Solidity contracts.
- Automated Deployment: Allows for contract deployment across supported EVM testnets without requiring a wallet.
- Code Review and Customization: Supports user interactions to fine-tune code before deployment.
- Error Handling and Debugging: Automatically resolves common errors and provides support for missing parameters or incorrect values.
- Automatic Verification: Contracts auto-verified on block explorers.
- IPFS Integration: Source files stored on IPFS.
- TokenScript Creation: Creates a TokenScript which enables users to view and interact with their deployed smart contract.
How to Use TokenScript Agent
1. Describe Your Idea
Begin by entering a natural language description of the smart contract you wish to create. For example:
Create an ERC721 NFT contract with metadata stored on IPFS.
2. Generate the Code
TokenScript Agent will analyze your input and generate Solidity code accordingly. You’ll receive:
An outline of the contract (e.g., ERC721 with OpenZeppelin libraries for security). Key features such as minting, ownership, and URI handling. The complete Solidity code for review.
3. Review and Edit
Automatic Suggestions: TokenScript Agent will propose code structure, security measures, and optional libraries. Customization: You can ask for specific changes, like adding functions or adjusting access control settings.
4. Deploy Your Contract
Once satisfied with the code:
Automatic Deployment: Type “Deploy to [Network Name]” to have the contract deployed on an EVM-compatible testnet. Manual Deployment: If manual deployment is preferred, connect your wallet and use the generated code.
5. TokenScript Creation
TokenScript Agent will create a TokenScript for the deployed contract and provide you with the details URl which users can use to view and interact with the deployed contract.
6. Error Handling
TokenScript Agent attempts to fix any compilation or deployment errors automatically. For complex issues, you may need to clarify or add specific parameters.
Example Walkthrough
Here’s a step-by-step example using TokenScript Agent to create and deploy an ERC721 NFT contract with metadata stored on IPFS:
1. Describe the Contract:
Create an ERC721 NFT contract with metadata stored on IPFS.
Web3GPT will generate the Solidity code for you:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts@4.9.3/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts@4.9.3/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts@4.9.3/access/Ownable.sol";
// ERC5169 interface declaration
interface IERC5169 {
event ScriptUpdate(string[]);
function scriptURI() external view returns (string[] memory);
function setScriptURI(string[] memory) external;
}
contract MyNFT is ERC721, ERC721Enumerable, Ownable, IERC5169 {
uint private _tokenIdCounter;
string private constant baseTokenURI = "ipfs://QmYourIPFSHashHere"; // Replace with your IPFS hash
constructor() ERC721("MyNFT", "MNFT") Ownable() {
_tokenIdCounter = 1;
mint();
}
function mint() public {
uint tokenId = _tokenIdCounter;
_safeMint(msg.sender, tokenId);
_tokenIdCounter++;
}
function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal override(ERC721,ERC721Enumerable) {
// Intentionally left blank
}
function tokenURI(uint256 tokenId)
public
pure
override(ERC721)
returns (string memory)
{
tokenId;
return baseTokenURI;
}
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721, ERC721Enumerable)
returns (bool)
{
return super.supportsInterface(interfaceId) || interfaceId == type(IERC5169).interfaceId;
}
string[] private _scriptURI;
function scriptURI() external view override returns (string[] memory) {
return _scriptURI;
}
function setScriptURI(string[] memory newScriptURI) external override onlyOwner {
_scriptURI = newScriptURI;
emit ScriptUpdate(newScriptURI);
}
}
2. Review Your Contract
Review Your Contract: Examine the generated code and request changes in chat if necessary. Ensure there are no omitted or placeholder sections.
3. Deploy Your Contract
Once satisfied with the code:
Automatic Deployment:
Prompt Web3GPT agent with:
Deploy to Sepolia
And you will get this response from Our AI agent:
The ERC721 NFT contract has been successfully deployed on the Sepolia network!
- Contract Address: 0x1D449aA762E5F0E6E35E0663226445b9ce11942a
- IPFS Repository: Source Code on IPFS
If you’d like to proceed with creating a TokenScript or need any further assistance, please let me know!
If the contract has Ownable access control, or has interactions with the deployer, you should provide your wallet address and request ownership of the contract in the chat.
Manual Deployment: Connect your wallet and click the Deploy Contract button above the source code to deploy the smart contract.
Results
View Deployment Results: Navigate to the explorer link. The contract will be automatically verified within 1 minute of deployment. Visit the IPFS directory to view source code and compilation files.
4. TokenScript Creation
Prompt Web3GPT agent with:
Create a TokenScript for this contract
And you will get this response from Our AI agent:
The TokenScript for the deployed NFT contract has been successfully created and uploaded. Here are the details:
- Transaction Explorer URL: View Transaction
- IPFS URL for TokenScript: IPFS Link
- Viewer URL: TokenScript Viewer
You can use the viewer URL to explore how your TokenScript looks and interacts with the smart contract. If there’s anything more you’d like to do, please let me know!
Errors
Handle Errors: If there are compilation errors, the agent will attempt to resolve them and show updates. For incorrect or missing parameters, the agent may retry or ask for additional information.
Join the Community
Web3GPT is revolutionizing smart contract development. Try it out today!
Start building at Web3GPT Token Agent .