-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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: Solana plugin improvement for flawless transfers #2340
Conversation
2bd8025
to
5fe1d4f
Compare
Head branch was pushed to by a user without write access
📝 WalkthroughWalkthroughThis pull request introduces significant updates to the Solana plugin, focusing on token and SOL transfer capabilities. A new character named SBF has been added, representing a crypto-savvy assistant specializing in Solana transfers. The changes involve updating action names, adding new transfer methods, and refining interaction logic across multiple files. The modifications enhance the plugin's functionality while maintaining its core structure. Changes
Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
🧹 Nitpick comments (2)
packages/plugin-solana/src/actions/transfer_sol.ts (1)
121-122
: Wait for Transaction ConfirmationImmediately after sending the transaction, wait for confirmation to ensure it was processed successfully.
Apply this diff:
const signature = await connection.sendTransaction(transaction); +await connection.confirmTransaction(signature, "confirmed");
README.md (1)
82-84
: Fix markdown formatting issues.
- Add language specifiers to fenced code blocks
- Add alt text to contributor image
-``` +```bash cp .env.example .env-
+
bash
pnpm install --include=optional sharp- <img src="https://contrib.rocks/image?repo=elizaos/eliza" /> + <img src="https://contrib.rocks/image?repo=elizaos/eliza" alt="Project contributors" />
Also applies to: 143-145, 163-164
🧰 Tools
🪛 Markdownlint (0.37.0)
82-82: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
.gitignore
(0 hunks)README.md
(1 hunks)characters/sbf.character.json
(1 hunks)packages/client-twitter/src/interactions.ts
(2 hunks)packages/plugin-solana/README.MD
(1 hunks)packages/plugin-solana/src/actions/transfer.ts
(5 hunks)packages/plugin-solana/src/actions/transfer_sol.ts
(1 hunks)packages/plugin-solana/src/index.ts
(1 hunks)
💤 Files with no reviewable changes (1)
- .gitignore
🧰 Additional context used
🪛 LanguageTool
README.md
[grammar] ~66-~66: This sentence should probably be started with a verb instead of the noun ‘Checkout’. If not, consider inserting a comma for better clarity.
Context: ...d if you know what you are doing) #### Checkout the latest release ```bash # Clone the...
(SENT_START_NN_DT)
[typographical] ~157-~157: Do not use a colon (:) before a series that is introduced by a preposition (‘for’). Remove the colon or add a noun or a noun phrase after the preposition.
Context: .../github.com/elizaos/eliza/issues). Best for: bugs you encounter using Eliza, and fea...
(RP_COLON)
🪛 Markdownlint (0.37.0)
README.md
82-82: null
Fenced code blocks should have a language specified
(MD040, fenced-code-language)
143-143: null
Fenced code blocks should have a language specified
(MD040, fenced-code-language)
163-163: null
Images should have alternate text (alt text)
(MD045, no-alt-text)
🔇 Additional comments (5)
packages/plugin-solana/src/index.ts (1)
7-14
: Verify Exported Modules IntegrationEnsure that all imported modules (
transferToken
,transferSol
, providers, and evaluators) are correctly exported and registered withinsolanaPlugin
.packages/plugin-solana/src/actions/transfer.ts (1)
68-68
: Simile Consistency for Action NamesConsider adding similes like "GIVE_TOKEN" or "SEND_ASSET" to cover a broader range of user commands.
packages/client-twitter/src/interactions.ts (2)
315-317
: LGTM! Enhanced self-tweet handling logic.The modified condition now correctly processes self-tweets when directed at target users, improving the interaction capabilities.
433-451
: LGTM! Improved state composition.The changes enhance context generation by:
- Converting arrays to strings consistently
- Including character examples for better response generation
characters/sbf.character.json (1)
31-75
: LGTM! Well-structured message examples.The message examples effectively demonstrate both SOL and token transfer actions with clear user interactions.
resolve conflicts/rebase and good to go |
Head branch was pushed to by a user without write access
…o develop * 'develop' of https://github.com/mgunnin/virtualDegen: (41 commits) Update README.md (elizaOS#2495) Update README_CN.md (elizaOS#2489) Update README_JA.md (elizaOS#2490) feat: introduce Dependency Injection to enhance developer experience (elizaOS#2115) chore: corrected the link to the banner (elizaOS#2491) chore: update createToken.ts (elizaOS#2493) feat: Solana plugin improvement for flawless transfers (elizaOS#2340) Update README_DE.md (elizaOS#2483) feat: Sui supports the secp256k1/secp256r1 algorithms (elizaOS#2476) chore: remove eslint, prettier, tslint and replace with biome (elizaOS#2439) chore: let -> const fix: lint command fix: unused import and type errors chore: console -> elizaLogger fix: error logging and remove unused import fix: remove unused error var chore: pnpm lock file add openai var Revert "Revert "refactor: dockerize smoke tests (elizaOS#2420)" (elizaOS#2459)" fix swaps evm plugin (elizaOS#2332) ...
Risks
Low risks, the only risk is that someone hooks up this plugin with their Solana wallet and because it is so easy to use spends more tokens than they wanted.
Background
Previous Solana plug-in simply did not work for transfering tokens - the transfer action was never triggered.
Improved Solana plug-in and added a new character who handles all Solana based transactions: SBF.
The transfer action in solana-plugin was split into two separate actions: SEND_SOL and SEND_TOKEN.
This way the agent can handle different transactions better than having both actions in one.
Also added more detailed logging and transaction state monitoring.
WARNING: as of this fresh release, there are yet no confirmations before sending out SOL or SPL tokens, so use for experimentation only.
SBF handles Solana transactions
As plugins and characters in Eliza agentic world go hand-in-hand, SBF is a character made for leveraging Solana plugin.
Setup the client
cp .env.example .env
Input your ANTHROPIC_API_KEY, SOLANA_PRIVATE_KEY and SOLANA_PUBLIC_KEY in .env.
I recommend using Anthropic's Claude, because the success rate of calling transfer actions is highly correlated with the intelligence of the AI used, but instead of ANTHROPIC_API_KEY, you can use any other model, so long as you specify it in the character.json file.
run
pnpm install --no-frozen-lockfile
andpnpm build
to install dependencies and build the project.run
pnpm start --character="characters/sbf.character.json"
to start SBF agent up.run
pnpm start:client
to start the client and chat with SBF using the client.NOTE: If something does not work, make the appropriate changes, delete the agent/data/db.sqlite file and
pnpm build
again to make sure your changes are reflected.Using the Solana plug-in
If you want the agent to send you SOL or SPL tokens, you need to simply tell the agent to do so.
For example type "send 1.5 SOL to Ae8GkmtaJmr3MS3oKStkZyPHuQf3hawn53XD4bQjVQiu".
This will send 1.5 SOL to the address Ae8GkmtaJmr3MS3oKStkZyPHuQf3hawn53XD4bQjVQiu.
For sending SPL native tokens, apart from the destination address and amount, the token contract address is also needed.
example:
"send 69 GODS (CA: GEVqugYZESSzZaYU6SKdpW6znCCEtH7aoSTzPHbqpump) to Ae8GkmtaJmr3MS3oKStkZyPHuQf3hawn53XD4bQjVQiu"
That's it. Upon success, you will be sent a transaction hash.
extra feats in client-twitter
I needed to run this plugin on Twitter so had to make sure it works with Twitter.
client-twitter was modified to a more sophisticated self-tweet handling - it will still process self-tweets if they're from target users.
Features:
What kind of change is this?
Bug fixes (non-breaking change which fixes an issue)
Improvements (misc. changes to existing features)
Features (non-breaking change which adds functionality)
Updates (new versions of included code)
Documentation changes needed?
Testing
run
pnpm install --no-frozen-lockfile
andpnpm build
to install dependencies and build the project.run
pnpm start --character="characters/sbf.character.json"
to start SBF agent up.run
pnpm start:client
to start the client and chat with SBF using the client.Discord username: sunsakis
This change has been discussed and blessed in ElizaOS Development server #pull-requests