@evvm/evvm-js
v0.1.17
Published
[](https://www.npmjs.com/package/@evvm/evvm-js) [](https://www.npmjs.com/package/@evvm/evvm-js) [;
const privateKey = "YOUR_PRIVATE_KEY";
const wallet = new ethers.Wallet(privateKey, provider);
const signer = await createSignerWithEthers(wallet);
// 2. Instantiate the EVVM service
const evvm = new EVVM({
signer,
address: "EVVM_CONTRACT_ADDRESS",
chainId: 1,
evvmId: 1, // optional
});
// 3. Call a method to create a signed action
const signedAction = await evvm.pay({
to: "RECIPIENT_ADDRESS",
tokenAddress: "TOKEN_ADDRESS",
amount: 100n, // Use BigInt for amounts
priorityFee: 0n,
nonce: 1n,
priorityFlag: false,
});
// 4. Execute the signed action
const result = await execute(signer, signedAction);
console.log(result);With Viem
import { EVVM } from "@evvm/evvm-js";
import { createSignerWithViem } from "@evvm/evvm-js/signers";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { mainnet } from "viem/chains";
// 1. Create a signer
const account = privateKeyToAccount("YOUR_PRIVATE_KEY");
const client = createWalletClient({
account,
chain: mainnet,
transport: http("YOUR_RPC_URL"),
});
const signer = await createSignerWithViem(client);
// 2. Instantiate the EVVM service
const evvm = new EVVM({
signer,
address: "EVVM_CONTRACT_ADDRESS",
chainId: 1,
});
// Continue with steps 3 and 4 exactly as shown in the ethers.js exampleAPI Reference
Services
EVVM: Core EVVM service for creating signed actions (payments, identity, staking, swaps).NameService: Manage identities.Staking: Handle staking operations.P2PSwap: Perform peer-to-peer swaps.
Each service is instantiated with a signer and a contract address.
Signers
EVVM JS provides an abstracted ISigner interface that allows seamless integration with various client-side Ethereum libraries. Helper functions are provided to create ISigner instances from ethers.js and viem wallets:
createSignerWithEthers: Creates a signer from anethers.jswallet.createSignerWithViem: Creates a signer from aviemwallet client.
Development
This project uses bun for package management and scripting.
Setup
bun installTesting
bun testBuilding
bun run buildContributing
Contributions are welcome! Please open an issue or submit a pull request on our GitHub repository.
