Vyper theorytheory 0/50 · 0%
Web3 integration · hard

49. Interacting with Vyper contracts from a dApp

Connecting a front end to a deployed contract.

A front end needs the deployed address and ABI to build a contract instance, then calls read (`view`) functions freely and prompts the user's wallet to sign write (state-changing) transactions.

import { createPublicClient, http, getContract } from "viem";

const contract = getContract({
  address: "0xYourContract",
  abi: vyperAbi,
  client: publicClient,
});

const rate = await contract.read.rate();

Writes go through the user's wallet (e.g. MetaMask) so they can review gas cost and the exact calldata before signing — the dApp never has custody of the user's private key.

Check your understanding

  1. 1. What two things does a front end need to interact with a deployed contract?

  2. 2. Who signs a state-changing (write) transaction?

  3. 3. Can view/read calls be made without a wallet signature?