Sending Transactions
Write to the chain.
Writing to the Chain
Changing contract state — transferring tokens, minting, voting — requires a transaction. Transactions must be signed and cost gas.
For this you need a signer, not just a provider.
A Contract with a Signer
To send transactions, create the contract with a signer or connect an existing instance to one:
const contract = new ethers.Contract(
address,
abi,
signer
);
// or
const writable = readOnly.connect(signer);Now state-changing functions become available.
const contract = new ethers.Contract(
address,
abi,
signer
);
// or
const writable = readOnly.connect(signer);All lessons in this course
- Connecting to a Provider
- Reading Contract Data
- Sending Transactions
- Listening to Events