-
Notifications
You must be signed in to change notification settings - Fork 755
Update defaults to smart wallet #622
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
71a671b
feat: improved wallet handling in smart wallet examples
CarsonRoscoe 62aef83
feat: updated pipx create-onchain-agent to default to smart wallets
CarsonRoscoe 005de27
feat: updated python examples to default to smart wallets
CarsonRoscoe b5b08e7
chore: updated python docs to refer to smart wallet example as the de…
CarsonRoscoe 6b3c0f0
feat: mcp example uses smart wallet
CarsonRoscoe b64256e
feat: updated vercel ai sdk example to use smart wallets
CarsonRoscoe 79b3e20
chore: updated typescript readmes to point to smart wallet as the bas…
CarsonRoscoe 32dbb7a
feat: updated defaults of openai agents sdk to smart wallet
CarsonRoscoe aad4a86
feat: updated npm create-onchain-agent to default to smart wallets
CarsonRoscoe c8a2b1f
chore: refactored folders that now use smart wallet to say it
CarsonRoscoe 764a6ae
chore: format/lint
CarsonRoscoe 54de972
chore: generated changesets
CarsonRoscoe f09df65
fix: mcp example uses same viem version as core
CarsonRoscoe a026fd5
fix: next example uses same viem version as core
CarsonRoscoe f4b6df7
chore: pr feedback
CarsonRoscoe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ | |
| **/__pycache__/ | ||
|
|
||
| # Wallet data | ||
| **/wallet_data.txt | ||
| **/wallet_data* | ||
|
|
||
| # Tools | ||
| **/.pytest_cache | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Updated default wallet provider to SmartWalletProvider |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,34 +22,32 @@ | |
| from langgraph.checkpoint.memory import MemorySaver | ||
| from langgraph.prebuilt import create_react_agent | ||
|
|
||
| wallet_data_file = "wallet_data.txt" | ||
|
|
||
| load_dotenv() | ||
|
|
||
|
|
||
| def initialize_agent(): | ||
| """Initialize the agent with SmartWalletProvider.""" | ||
| llm = ChatOpenAI(model="gpt-4o-mini") | ||
|
|
||
| network_id = os.getenv("NETWORK_ID", "base-sepolia") | ||
| wallet_data_file = f"wallet_data_{network_id.replace('-', '_')}.txt" | ||
|
|
||
| # Load wallet data from JSON file | ||
| wallet_data = {"private_key": None, "smart_wallet_address": None} | ||
| if os.path.exists(wallet_data_file): | ||
| try: | ||
| with open(wallet_data_file) as f: | ||
| wallet_data = json.load(f) | ||
| except json.JSONDecodeError: | ||
| print("Warning: Invalid wallet data file format. Creating new wallet.") | ||
| print(f"Warning: Invalid wallet data file format for {network_id}. Creating new wallet.") | ||
|
|
||
| # Use private key from env if not in wallet data | ||
| private_key = wallet_data.get("private_key") or os.getenv("PRIVATE_KEY") | ||
|
|
||
| if not private_key: | ||
| raise ValueError("PRIVATE_KEY environment variable is required") | ||
| acct = Account.create() | ||
| private_key = acct.key.hex() | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another generate improvement. If a private key is not set, generate one instead of throw an error |
||
|
|
||
| signer = Account.from_key(private_key) | ||
|
|
||
| network_id = os.getenv("NETWORK_ID", "base-sepolia") | ||
|
|
||
| # Initialize CDP Wallet Provider | ||
| wallet_provider = SmartWalletProvider( | ||
| SmartWalletProviderConfig( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
.../openai-agents-sdk-cdp-chatbot/.env.local → ...gents-sdk-smart-wallet-chatbot/.env.local
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| CDP_API_KEY_NAME= # Place your CDP API key name here | ||
| CDP_API_KEY_PRIVATE_KEY= # Place your CDP API key private key here | ||
| OPENAI_API_KEY= # Place your OpenAI API key here | ||
| PRIVATE_KEY= # Place your private key here |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "create-onchain-agent": minor | ||
| --- | ||
|
|
||
| Updated default wallet provider to SmartWalletProvider |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I wanted to improve the smart wallet examples before I copied their code into other examples.
This improvement is regarding switching networks. Now, rather than a
wallet_data.txtfile that cannot change networks, each network will generate a different wallet file, e.g.wallet_data_base_sepolia.txtandwallet_data_base_mainnet.txt