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

Unable to use plugin-evm #3380

Open
tskoyo opened this issue Feb 8, 2025 · 3 comments
Open

Unable to use plugin-evm #3380

tskoyo opened this issue Feb 8, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@tskoyo
Copy link

tskoyo commented Feb 8, 2025

Describe the bug

I installed plugin-evm with pnpm install @elizaos/plugin-evm,

added values for these attributes in the .env file:

EVM_PRIVATE_KEY=my-private-key
EVM_PROVIDER_URL=rpc-url

Added also in my character json file:

"settings": {
    "chains": {
          "evm": ["base"]
     }
},

When I run pnpm start --character="path/to/my/character.json I get this error:

invalid private key, expected hex or 32 bytes, got string

When I inspected the logs, I saw that only one part of my private key I pasted was used, not the whole value.

To Reproduce

Explained above

Expected behavior

I can run plugin-evm

Screenshots

Additional context

@tskoyo tskoyo added the bug Something isn't working label Feb 8, 2025
@pallyndr
Copy link

pallyndr commented Feb 9, 2025

Same problem here:
[2025-02-09 10:54:10] ERROR:
err: {
"type": "Error",
"message": "invalid private key, expected hex or 32 bytes, got string",
"stack":
Error: invalid private key, expected hex or 32 bytes, got string
at normPrivateKeyToScalar (file:///Users/pierreallyndree/Documents/eliza/node_modules/viem/node_modules/@noble/curves/esm/abstract/weierstrass.js:218:19)
at Point.fromPrivateKey (file:///Users/pierreallyndree/Documents/eliza/node_modules/viem/node_modules/@noble/curves/esm/abstract/weierstrass.js:335:40)
at Object.getPublicKey (file:///Users/pierreallyndree/Documents/eliza/node_modules/viem/node_modules/@noble/curves/esm/abstract/weierstrass.js:804:22)
at privateKeyToAccount (file:///Users/pierreallyndree/Documents/eliza/node_modules/viem/_esm/accounts/privateKeyToAccount.js:17:39)
at getWalletClient (file:///Users/pierreallyndree/Documents/eliza/packages/plugin-goat/dist/index.js:168:18)
at createGoatPlugin (file:///Users/pierreallyndree/Documents/eliza/packages/plugin-goat/dist/index.js:192:26)
at createAgent (file:///Users/pierreallyndree/Documents/eliza/agent/src/index.ts:731:28)
at startAgent (file:///Users/pierreallyndree/Documents/eliza/agent/src/index.ts:1136:31)
at async startAgents (file:///Users/pierreallyndree/Documents/eliza/agent/src/index.ts:1191:13)
}

Used the Metamask generated private key for my Ethereum account. Seems there needs to be conversion to happen.

@pallyndr
Copy link

pallyndr commented Feb 9, 2025

So, here is info from Gemini AI:

EVM (Ethereum Virtual Machine) private keys are typically represented in a few different formats, all essentially representing the same underlying cryptographic data. Here's a breakdown of the common formats:

Hexadecimal (Private Key): This is the most common and fundamental format. It's a 64-character hexadecimal string representing the private key. Each character represents 4 bits of data, so 64 hex characters represent 256 bits (the size of an EVM private key).

Example: 0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef (This is just a random example; never use this key).
Wallet Import Format (WIF): WIF is a base58 encoded version of the private key, often used for importing and exporting keys. It's designed to be more human-readable and less error-prone than the raw hexadecimal format. WIF can also include information about the network (e.g., Ethereum mainnet or testnet). WIF keys usually start with a letter (like K or L for uncompressed keys and 5 for compressed keys).

Example (Uncompressed): Kwb9JzM9mXjLg869p8cVeSnc9k4t9xUj2gYt9529999999999999 (This is a fictional example).
Example (Compressed): 5HpHagT65U9223cT79999999999999999999999999999999999999999999999999 (This is a fictional example).
Mnemonic Phrase (Seed Phrase): This is a human-readable list of 12, 15, 18, or 24 words generated using a BIP39 standard. The mnemonic phrase acts as a master seed from which an unlimited number of private keys can be derived. This is the most secure way to store your keys because it's easier to back up and less prone to errors than handling raw private keys.

Example: abandon ability able about above absent absorb abstract absurd abuse access accident ... (This is just a partial example; a real seed phrase would have 12, 15, 18, or 24 words).

@pallyndr
Copy link

pallyndr commented Feb 9, 2025

So what worked from me: I just added a 0x at the beginning of my private key, as I checked if was all hexa (from 0 to f).

Bingo! worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants