EVM Interactions
Send a transaction on Ethereum/EVM
The Basics
- Installing Dynamic
- Chains / Networks
- Authentication
- Wallets
- Set Up Embedded Wallets
- Set Up Branded Wallets
- Smart Wallets
- Using Wallets
- Accessing Wallets
- Interacting with wallets
- General Interactions
- EVM Interactions
- Bitcoin Interactions
- Solana Interactions
- Multi Wallet
- Multi Asset UI
- Send Assets
- Users / VC's
- Design
- Onramps
Beyond The Basics
- Headless
- Cross-ecosystem Connectivity
- Bridge Widget
- Rate Limits
Developer Dashboard
- SDK and API Keys
- Sandbox vs Live
- Analytics
- User Management
- Test Accounts
- Settings
- Admin
- Webhooks
- Configuring Social Providers
Tutorials
- Farcaster
- Telegram
- Features
- Frameworks
- Integrations
- Webhooks
Migrating to Dynamic
- Migrating to Dynamic
- Migration Tutorials
For Wallets & Chains
Hackathons
EVM Interactions
Send a transaction on Ethereum/EVM
import { FC, FormEventHandler, useState } from "react";
import { parseEther } from "viem";
import { useDynamicContext } from "@dynamic-labs/sdk-react-core";
import { isEthereumWallet } from "@dynamic-labs/ethereum";
export const SendTransactionSection: FC = () => {
const { primaryWallet } = useDynamicContext();
const [txnHash, setTxnHash] = useState("");
if (!primaryWallet || !isEthereumWallet(primaryWallet)) return null;
const onSubmit: FormEventHandler<HTMLFormElement> = async (event) => {
event.preventDefault();
const formData = new FormData(event.currentTarget);
const address = formData.get("address") as string;
const amount = formData.get("amount") as string;
const publicClient = await primaryWallet.getPublicClient();
const walletClient = await primaryWallet.getWalletClient();
const transaction = {
to: address,
value: amount ? parseEther(amount) : undefined,
};
const hash = await walletClient.sendTransaction(transaction);
setTxnHash(hash);
const receipt = await publicClient.getTransactionReceipt({
hash,
});
console.log(receipt);
};
return (
<form onSubmit={onSubmit}>
<p>Send to ETH address</p>
<input name="address" type="text" required placeholder="Address" />
<input name="amount" type="text" required placeholder="0.05" />
<button type="submit">Send</button>
<span data-testid="transaction-section-result-hash">{txnHash}</span>
</form>
);
};
Was this page helpful?