Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Conflux plugin #481

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,18 @@ STARKNET_ADDRESS=
STARKNET_PRIVATE_KEY=
STARKNET_RPC_URL=

# Conflux Configuration
CONFLUX_CORE_PRIVATE_KEY=
CONFLUX_CORE_SPACE_RPC_URL=
CONFLUX_ESPACE_PRIVATE_KEY=
CONFLUX_ESPACE_RPC_URL=
CONFLUX_MEME_CONTRACT_ADDRESS=

# Coinbase
COINBASE_COMMERCE_KEY= # from coinbase developer portal
COINBASE_API_KEY= # from coinbase developer portal
COINBASE_PRIVATE_KEY= # from coinbase developer portal
# if not configured it will be generated and written to runtime.character.settings.secrets.COINBASE_GENERATED_WALLET_ID and runtime.character.settings.secrets.COINBASE_GENERATED_WALLET_HEX_SEED
COINBASE_GENERATED_WALLET_ID= # not your address but the wallet id from generating a wallet through the plugin
COINBASE_GENERATED_WALLET_HEX_SEED= # not your address but the wallet hex seed from generating a wallet through the plugin and calling export

1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@ai16z/client-twitter": "workspace:*",
"@ai16z/eliza": "workspace:*",
"@ai16z/plugin-bootstrap": "workspace:*",
"@ai16z/plugin-conflux": "workspace:*",
"@ai16z/plugin-image-generation": "workspace:*",
"@ai16z/plugin-node": "workspace:*",
"@ai16z/plugin-solana": "workspace:*",
Expand Down
4 changes: 4 additions & 0 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
validateCharacterConfig,
} from "@ai16z/eliza";
import { bootstrapPlugin } from "@ai16z/plugin-bootstrap";
import { confluxPlugin } from "@ai16z/plugin-conflux";
import { solanaPlugin } from "@ai16z/plugin-solana";
import { nodePlugin } from "@ai16z/plugin-node";
import {
Expand Down Expand Up @@ -252,6 +253,9 @@ export function createAgent(
character,
plugins: [
bootstrapPlugin,
character.settings.secrets?.CONFLUX_CORE_PRIVATE_KEY
? confluxPlugin
: null,
nodePlugin,
character.settings.secrets?.WALLET_PUBLIC_KEY ? solanaPlugin : null,
character.settings.secrets?.COINBASE_COMMERCE_KEY ||
Expand Down
25 changes: 25 additions & 0 deletions packages/plugin-conflux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# @ai16z/plugin-conflux

This plugin provides actions and providers for interacting with the [Conflux network](https://www.confluxdocs.com/docs/general).

## Actions

### ConfiPump

Buy and sell tokens on Conflux's implementation of pump.fun (ConfiPump).

### Transfer

Transfer tokens from one address to another within Conflux core space.

### Bridge Transfer

Transfer tokens from one address to Conflux eSpace.

### Sponsor (TBD)

Provide gas for Conflux core space contracts so they can be called without the need to have Conflux in user's wallet.

### Swap (TBD)

Swap tokens on Conflux DEXs.
15 changes: 15 additions & 0 deletions packages/plugin-conflux/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@ai16z/plugin-conflux",
"version": "0.0.1",
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
"dependencies": {
"cive": "^0.7.1",
"@ai16z/eliza": "workspace:*"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --watch"
}
}
184 changes: 184 additions & 0 deletions packages/plugin-conflux/src/abi/crossSpaceCall.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
const CrossSpaceCallAbi = [
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "bytes20",
name: "sender",
type: "bytes20",
},
{
indexed: true,
internalType: "bytes20",
name: "receiver",
type: "bytes20",
},
{
indexed: false,
internalType: "uint256",
name: "value",
type: "uint256",
},
{
indexed: false,
internalType: "uint256",
name: "nonce",
type: "uint256",
},
{
indexed: false,
internalType: "bytes",
name: "data",
type: "bytes",
},
],
name: "Call",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "bytes20",
name: "sender",
type: "bytes20",
},
{
indexed: true,
internalType: "bytes20",
name: "contract_address",
type: "bytes20",
},
{
indexed: false,
internalType: "uint256",
name: "value",
type: "uint256",
},
{
indexed: false,
internalType: "uint256",
name: "nonce",
type: "uint256",
},
{
indexed: false,
internalType: "bytes",
name: "init",
type: "bytes",
},
],
name: "Create",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "bool",
name: "success",
type: "bool",
},
],
name: "Outcome",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "bytes20",
name: "sender",
type: "bytes20",
},
{
indexed: true,
internalType: "address",
name: "receiver",
type: "address",
},
{
indexed: false,
internalType: "uint256",
name: "value",
type: "uint256",
},
{
indexed: false,
internalType: "uint256",
name: "nonce",
type: "uint256",
},
],
name: "Withdraw",
type: "event",
},
{
inputs: [{ internalType: "bytes", name: "init", type: "bytes" }],
name: "createEVM",
outputs: [{ internalType: "bytes20", name: "", type: "bytes20" }],
stateMutability: "payable",
type: "function",
},
{
inputs: [{ internalType: "bytes20", name: "to", type: "bytes20" }],
name: "transferEVM",
outputs: [{ internalType: "bytes", name: "output", type: "bytes" }],
stateMutability: "payable",
type: "function",
},
{
inputs: [
{ internalType: "bytes20", name: "to", type: "bytes20" },
{ internalType: "bytes", name: "data", type: "bytes" },
],
name: "callEVM",
outputs: [{ internalType: "bytes", name: "output", type: "bytes" }],
stateMutability: "payable",
type: "function",
},
{
inputs: [
{ internalType: "bytes20", name: "to", type: "bytes20" },
{ internalType: "bytes", name: "data", type: "bytes" },
],
name: "staticCallEVM",
outputs: [{ internalType: "bytes", name: "output", type: "bytes" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "deployEip1820",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [{ internalType: "uint256", name: "value", type: "uint256" }],
name: "withdrawFromMapped",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [{ internalType: "address", name: "addr", type: "address" }],
name: "mappedBalance",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
{
inputs: [{ internalType: "address", name: "addr", type: "address" }],
name: "mappedNonce",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
];

export default CrossSpaceCallAbi;
119 changes: 119 additions & 0 deletions packages/plugin-conflux/src/abi/erc20.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
const ERC20ABI = [
{
constant: true,
inputs: [],
name: 'name',
outputs: [{ name: '', type: 'string' }],
payable: false,
stateMutability: 'view',
type: 'function',
},
{
constant: false,
inputs: [
{ name: '_spender', type: 'address' },
{ name: '_value', type: 'uint256' },
],
name: 'approve',
outputs: [{ name: '', type: 'bool' }],
payable: false,
stateMutability: 'view',
type: 'function',
},
{
constant: true,
inputs: [],
name: 'totalSupply',
outputs: [{ name: '', type: 'uint256' }],
payable: false,
stateMutability: 'view',
type: 'function',
},
{
constant: false,
inputs: [
{ name: '_from', type: 'address' },
{ name: '_to', type: 'address' },
{ name: '_value', type: 'uint256' },
],
name: 'transferFrom',
outputs: [{ name: '', type: 'bool' }],
payable: false,
stateMutability: 'nonpayable',
type: 'function',
},
{
constant: true,
inputs: [],
name: 'decimals',
outputs: [{ name: '', type: 'uint8' }],
payable: false,
stateMutability: 'view',
type: 'function',
},
{
constant: true,
inputs: [{ name: '_owner', type: 'address' }],
name: 'balanceOf',
outputs: [{ name: 'balance', type: 'uint256' }],
payable: false,
stateMutability: 'view',
type: 'function',
},
{
constant: true,
inputs: [],
name: 'symbol',
outputs: [{ name: '', type: 'string' }],
payable: false,
stateMutability: 'view',
type: 'function',
},
{
constant: false,
inputs: [
{ name: '_to', type: 'address' },
{ name: '_value', type: 'uint256' },
],
name: 'transfer',
outputs: [{ name: '', type: 'bool' }],
payable: false,
stateMutability: 'nonpayable',
type: 'function',
},
{
constant: true,
inputs: [
{ name: '_owner', type: 'address' },
{ name: '_spender', type: 'address' },
],
name: 'allowance',
outputs: [{ name: '', type: 'uint256' }],
payable: false,
stateMutability: 'view',
type: 'function',
},
{ payable: true, stateMutability: 'payable', type: 'fallback' },
{
anonymous: false,
inputs: [
{ indexed: true, name: 'owner', type: 'address' },
{ indexed: true, name: 'spender', type: 'address' },
{ indexed: false, name: 'value', type: 'uint256' },
],
name: 'Approval',
type: 'event',
},
{
anonymous: false,
inputs: [
{ indexed: true, name: 'from', type: 'address' },
{ indexed: true, name: 'to', type: 'address' },
{ indexed: false, name: 'value', type: 'uint256' },
],
name: 'Transfer',
type: 'event',
},
] as const;

export default ERC20ABI;
Loading