Skip to content

Commit

Permalink
Merge branch 'conflux-plugin' of https://github.com/conflux-fans/eliza
Browse files Browse the repository at this point in the history
…into HEAD
  • Loading branch information
lalalune committed Nov 25, 2024
2 parents 0ffa45c + fd83efa commit edecd95
Show file tree
Hide file tree
Showing 19 changed files with 2,772 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,14 @@ 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

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

# Coinbase Commerce
COINBASE_COMMERCE_KEY=

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

0 comments on commit edecd95

Please sign in to comment.