EVM Interactions
Mint an NFT on EVM with Wagmi
Configurations
- Installing Dynamic
- Chains/Networks
- Authentication
- Wallets
- Setup Embedded Wallets
- Setup Branded Wallets
- Add Account Abstraction
- Using Wallets
- Accessing Wallets
- Connecting Wallets
- Interacting with wallets
- General Interactions
- EVM Interactions
- Bitcoin Interactions
- Solana Interactions
- Multi Asset UI
- Users / VC's
- Design
- Headless
- Onramps
- Bridges
Developer Dashboard
- SDK and API Keys
- Sandbox vs Live
- Analytics
- User Management
- Settings
- Admin
- Webhooks
- Configuring Social Providers
Tutorials
- Farcaster
- Features
- Frameworks
- Integrations
- Webhooks
Migrating to Dynamic
- Migrating to Dynamic
- Migration Tutorials
Troubleshooting
- Dynamic Doctor
- React Issues
- NextJS Issues
- Wallet Issues
- WalletConnect Issues
- Solved Issues
EVM Interactions
Mint an NFT on EVM with Wagmi
import { FC } from 'react';
import {
useContractWrite,
usePrepareContractWrite,
useWaitForTransaction,
} from 'wagmi';
export const ContractWriteSection: FC = () => {
const { config } = usePrepareContractWrite({
abi: [
{
inputs: [],
name: 'mint',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
] as const,
address: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
functionName: 'mint',
});
const { data, write } = useContractWrite(config);
const { isLoading, isSuccess } = useWaitForTransaction({
hash: data?.hash,
});
return (
<div>
<p>Mint NFT</p>
<button disabled={!write || isLoading} onClick={() => write?.()}>
{isLoading ? 'Minting...' : 'Mint'}
</button>
{isSuccess && (
<div>
Successfully minted your NFT!
<div>
<a href={`https://etherscan.io/tx/${data?.hash}`}>Etherscan</a>
</div>
</div>
)}
</div>
);
};
Was this page helpful?