Skip to content

Commit f2f567d

Browse files
authored
Merge pull request #803 from monilpat/realitySpiral/tokenContractPlugin
feat: add coinbase ERC20, ERC721, and ERC1155 tokenContract deployment / invokement plugin
2 parents 892831a + 75c4a2f commit f2f567d

File tree

7 files changed

+911
-6
lines changed

7 files changed

+911
-6
lines changed

agent/src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
coinbaseCommercePlugin,
3131
coinbaseMassPaymentsPlugin,
3232
tradePlugin,
33+
tokenContractPlugin,
3334
} from "@ai16z/plugin-coinbase";
3435
import { confluxPlugin } from "@ai16z/plugin-conflux";
3536
import { imageGenerationPlugin } from "@ai16z/plugin-image-generation";
@@ -388,7 +389,7 @@ export function createAgent(
388389
: null,
389390
...(getSecret(character, "COINBASE_API_KEY") &&
390391
getSecret(character, "COINBASE_PRIVATE_KEY")
391-
? [coinbaseMassPaymentsPlugin, tradePlugin]
392+
? [coinbaseMassPaymentsPlugin, tradePlugin, tokenContractPlugin]
392393
: []),
393394
getSecret(character, "WALLET_SECRET_SALT") ? teePlugin : null,
394395
getSecret(character, "ALCHEMY_API_KEY") ? goatPlugin : null,

docs/docs/packages/plugins.md

+140
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,146 @@ When successful, a response similar to the following will be returned:
481481

482482
---
483483

484+
#### 8. Coinbase Token Contract Plugin (`@eliza/plugin-coinbase`)
485+
486+
This plugin enables the deployment and interaction with various token contracts (ERC20, ERC721, ERC1155) using the Coinbase SDK. It provides functionality for both deploying new token contracts and interacting with existing ones.
487+
488+
**Actions:**
489+
490+
1. `DEPLOY_TOKEN_CONTRACT`
491+
Deploys a new token contract (ERC20, ERC721, or ERC1155).
492+
- **Inputs**:
493+
- `contractType` (string): Type of contract to deploy (`ERC20`, `ERC721`, or `ERC1155`)
494+
- `name` (string): Name of the token
495+
- `symbol` (string): Symbol of the token
496+
- `network` (string): Blockchain network to deploy on
497+
- `baseURI` (string, optional): Base URI for token metadata (required for ERC721 and ERC1155)
498+
- `totalSupply` (number, optional): Total supply of tokens (only for ERC20)
499+
- **Example**:
500+
```json
501+
{
502+
"contractType": "ERC20",
503+
"name": "MyToken",
504+
"symbol": "MTK",
505+
"network": "base",
506+
"totalSupply": 1000000
507+
}
508+
```
509+
510+
2. `INVOKE_CONTRACT`
511+
Invokes a method on a deployed smart contract.
512+
- **Inputs**:
513+
- `contractAddress` (string): Address of the contract to invoke
514+
- `method` (string): Method name to invoke
515+
- `abi` (array): Contract ABI
516+
- `args` (object, optional): Arguments for the method
517+
- `amount` (number, optional): Amount of asset to send (for payable methods)
518+
- `assetId` (string, optional): Asset ID to send
519+
- `network` (string): Blockchain network to use
520+
- **Example**:
521+
```json
522+
{
523+
"contractAddress": "0x123...",
524+
"method": "transfer",
525+
"abi": [...],
526+
"args": {
527+
"to": "0x456...",
528+
"amount": "1000000000000000000"
529+
},
530+
"network": "base"
531+
}
532+
```
533+
534+
**Description:**
535+
536+
The Coinbase Token Contract plugin simplifies the process of deploying and interacting with various token contracts on supported blockchain networks. It supports:
537+
538+
- ERC20 token deployment with customizable supply
539+
- ERC721 (NFT) deployment with metadata URI support
540+
- ERC1155 (Multi-token) deployment with metadata URI support
541+
- Contract method invocation for deployed contracts
542+
543+
All contract deployments and interactions are logged to a CSV file for record-keeping and auditing purposes.
544+
545+
**Usage Instructions:**
546+
547+
1. **Configure the Plugin**
548+
Add the plugin to your character's configuration:
549+
550+
```typescript
551+
import { tokenContractPlugin } from "@eliza/plugin-coinbase";
552+
553+
const character = {
554+
plugins: [tokenContractPlugin],
555+
};
556+
```
557+
558+
2. **Required Configurations**
559+
Ensure the following environment variables or runtime settings are configured:
560+
- `COINBASE_API_KEY`: API key for Coinbase SDK
561+
- `COINBASE_PRIVATE_KEY`: Private key for secure transactions
562+
- Wallet configuration (same as MassPayments plugin)
563+
564+
**Example Deployments:**
565+
566+
1. **ERC20 Token**
567+
```typescript
568+
const response = await runtime.triggerAction("DEPLOY_TOKEN_CONTRACT", {
569+
contractType: "ERC20",
570+
name: "MyToken",
571+
symbol: "MTK",
572+
network: "base",
573+
totalSupply: 1000000
574+
});
575+
```
576+
577+
2. **NFT Collection**
578+
```typescript
579+
const response = await runtime.triggerAction("DEPLOY_TOKEN_CONTRACT", {
580+
contractType: "ERC721",
581+
name: "MyNFT",
582+
symbol: "MNFT",
583+
network: "eth",
584+
baseURI: "https://api.mynft.com/metadata/"
585+
});
586+
```
587+
588+
3. **Multi-token Collection**
589+
```typescript
590+
const response = await runtime.triggerAction("DEPLOY_TOKEN_CONTRACT", {
591+
contractType: "ERC1155",
592+
name: "MyMultiToken",
593+
symbol: "MMT",
594+
network: "pol",
595+
baseURI: "https://api.mymultitoken.com/metadata/"
596+
});
597+
```
598+
599+
**Contract Interaction Example:**
600+
601+
```typescript
602+
const response = await runtime.triggerAction("INVOKE_CONTRACT", {
603+
contractAddress: "0x123...",
604+
method: "transfer",
605+
abi: [...],
606+
args: {
607+
to: "0x456...",
608+
amount: "1000000000000000000"
609+
},
610+
network: "base"
611+
});
612+
```
613+
614+
**Best Practices:**
615+
616+
- Always verify contract parameters before deployment
617+
- Store contract addresses and deployment details securely
618+
- Test contract interactions on testnets before mainnet deployment
619+
- Keep track of deployed contracts using the generated CSV logs
620+
- Ensure proper error handling for failed deployments or interactions
621+
622+
---
623+
484624
#### 7. TEE Plugin (`@ai16z/plugin-tee`)
485625

486626
Integrates [Dstack SDK](https://github.com/Dstack-TEE/dstack) to enable TEE (Trusted Execution Environment) functionality and deploy secure & privacy-enhanced Eliza Agents:

packages/plugin-coinbase/src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { coinbaseMassPaymentsPlugin } from "./plugins/massPayments";
22
import { coinbaseCommercePlugin } from "./plugins/commerce";
33
import { tradePlugin } from "./plugins/trade";
4+
import { tokenContractPlugin } from "./plugins/tokenContract";
45

56
export const plugins = {
67
coinbaseMassPaymentsPlugin,
78
coinbaseCommercePlugin,
89
tradePlugin,
10+
tokenContractPlugin,
911
};
1012

1113
export * from "./plugins/massPayments";
1214
export * from "./plugins/commerce";
1315
export * from "./plugins/trade";
16+
export * from "./plugins/tokenContract";

0 commit comments

Comments
 (0)