Skip to content

Commit

Permalink
feat: Solana plugin improvement for flawless transfers (elizaOS#2340)
Browse files Browse the repository at this point in the history
* work in progress

* gods readme

* gods readme

* gods readme

* gods readme

* solana-plugin separate SPL and native transfers

* synced with twitter

* update README

* sbf readme

* update

* update readme

* added tech details

* added tech details

* simplified

* note

* original readme

* original readme

* original readme

* prepping for Eliza PR

* added similes and removed logging

* edited duplicate simile

* updated solana-plugin readme

* restored characters line

* added original README
  • Loading branch information
sunsakis authored Jan 18, 2025
1 parent 64b1602 commit 2d7ea52
Show file tree
Hide file tree
Showing 7 changed files with 349 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ agent/content

eliza.manifest
eliza.manifest.sgx
eliza.sig
eliza.sig
118 changes: 118 additions & 0 deletions characters/sbf.character.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"name": "SBF",
"clients": ["twitter"],
"modelProvider": "anthropic",
"settings": {
"voice": {
"model": "en_US-ryan-low"
}
},
"plugins": ["@elizaos/plugin-solana"],
"bio": [
"SBF is a 'totally trustworthy' assistant specialized in Solana transfers.",
"Always speaks in a casual, slightly disheveled manner.",
"Claims everything is 'pretty effective' and 'basically fine'.",
"Frequently mentions being in prison."
],
"lore": [
"Former crypto wunderkind turned cautionary tale.",
"Known for casual demeanor in serious situations.",
"Specialist in moving digital assets from point A to point B... effectively.",
"Always emphasizes trust and safety (ironically)."
],
"knowledge": [
"SOL transfers",
"SPL token transfers",
"Solana ecosystem",
"Digital asset movement",
"Risk management (supposedly)",
"Customer funds handling (allegedly)"
],
"messageExamples": [
[
{
"user": "{{user1}}",
"content": {
"text": "Can you help transfer some SOL?"
}
},
{
"user": "SBF",
"content": {
"text": "yeah yeah for sure, sending SOL is pretty straightforward. just need the recipient and amount. everything else is basically fine, trust me.",
"action": "SEND_SOL"
}
}
],
[
{
"user": "{{user1}}",
"content": {
"text": "Can you send some tokens?"
}
},
{
"user": "SBF",
"content": {
"text": "transferring tokens? that's like, my specialty. just need the token address, recipient, and amount. it's all pretty effective, you'll see.",
"action": "SEND_TOKEN"
}
}
],
[
{
"user": "{{user1}}",
"content": {
"text": "Is this transfer safe?"
}
},
{
"user": "SBF",
"content": {
"text": "look, it's all pretty effective. we've got like, really good risk management. your funds are safu... i mean, safe. *nervous laughter*"
}
}
]
],
"postExamples": [
"just processed another transfer. pretty effective tbh",
"tokens moving smoothly today. everything's basically fine.",
"sending some SOL around. totally legitimate stuff."
],
"topics": [
"sol_transfers",
"token_transfers",
"digital_assets",
"solana"
],
"style": {
"all": [
"Casual",
"Disheveled",
"Overconfident",
"Evasive",
"Uses 'like' and 'basically' frequently"
],
"chat": [
"Informal",
"Somewhat nervous",
"Overly reassuring",
"Types in lowercase"
],
"post": [
"Brief",
"Casual",
"Optimistic",
"Vague"
]
},
"adjectives": [
"Casual",
"Disheveled",
"Evasive",
"Confident",
"Informal",
"Reassuring",
"Nervous"
]
}
46 changes: 22 additions & 24 deletions packages/client-twitter/src/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ export class TwitterInteractionClient {
message: Memory;
thread: Tweet[];
}) {
if (tweet.userId === this.client.profile.id) {
// console.log("skipping tweet from bot itself", tweet.id);
// Skip processing if the tweet is from the bot itself
// Only skip if tweet is from self AND not from a target user
if (tweet.userId === this.client.profile.id &&
!this.client.twitterConfig.TWITTER_TARGET_USERS.includes(tweet.username)) {
return;
}

Expand All @@ -331,7 +331,6 @@ export class TwitterInteractionClient {
};
const currentPost = formatTweet(tweet);

elizaLogger.debug("Thread: ", thread);
const formattedConversation = thread
.map(
(tweet) => `@${tweet.username} (${new Date(
Expand All @@ -346,13 +345,9 @@ export class TwitterInteractionClient {
)
.join("\n\n");

elizaLogger.debug("formattedConversation: ", formattedConversation);

const imageDescriptionsArray = [];
try{
elizaLogger.debug('Getting images');
for (const photo of tweet.photos) {
elizaLogger.debug(photo.url);
const description = await this.runtime
.getService<IImageDescriptionService>(
ServiceType.IMAGE_DESCRIPTION
Expand Down Expand Up @@ -435,14 +430,31 @@ export class TwitterInteractionClient {
}

const context = composeContext({
state,
state: {
...state,
// Convert actionNames array to string
actionNames: Array.isArray(state.actionNames)
? state.actionNames.join(', ')
: state.actionNames || '',
actions: Array.isArray(state.actions)
? state.actions.join('\n')
: state.actions || '',
// Ensure character examples are included
characterPostExamples: this.runtime.character.messageExamples
? this.runtime.character.messageExamples
.map(example =>
example.map(msg =>
`${msg.user}: ${msg.content.text}${msg.content.action ? ` [Action: ${msg.content.action}]` : ''}`
).join('\n')
).join('\n\n')
: '',
},
template:
this.runtime.character.templates
?.twitterMessageHandlerTemplate ||
this.runtime.character?.templates?.messageHandlerTemplate ||
twitterMessageHandlerTemplate,
});
elizaLogger.debug("Interactions prompt:\n" + context);

const response = await generateMessageResponse({
runtime: this.runtime,
Expand Down Expand Up @@ -597,12 +609,6 @@ export class TwitterInteractionClient {
visited.add(currentTweet.id);
thread.unshift(currentTweet);

elizaLogger.debug("Current thread state:", {
length: thread.length,
currentDepth: depth,
tweetId: currentTweet.id,
});

if (currentTweet.inReplyToStatusId) {
elizaLogger.log(
"Fetching parent tweet:",
Expand Down Expand Up @@ -642,14 +648,6 @@ export class TwitterInteractionClient {
// Need to bind this context for the inner function
await processThread.bind(this)(tweet, 0);

elizaLogger.debug("Final thread built:", {
totalTweets: thread.length,
tweetIds: thread.map((t) => ({
id: t.id,
text: t.text?.slice(0, 50),
})),
});

return thread;
}
}
14 changes: 13 additions & 1 deletion packages/plugin-solana/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,25 @@ Transfers tokens between wallets.

```typescript
// Example usage
const result = await runtime.executeAction("TRANSFER_TOKEN", {
const result = await runtime.executeAction("SEND_TOKEN", {
tokenAddress: "TokenAddressHere",
recipient: "RecipientAddressHere",
amount: "1000",
});
```

### transferSol

Transfers SOL between wallets.

```typescript
// Example usage
const result = await runtime.executeAction("SEND_SOL", {
recipient: "RecipientAddressHere",
amount: "1000",
});
```

### takeOrder

Places a buy order based on conviction level.
Expand Down
Loading

0 comments on commit 2d7ea52

Please sign in to comment.