UniswapV2Router02

Base
basescoutdexguru

Getting Started

Choose a language:

Install the latest version of the SDK:

npm i thirdweb

Initialize the SDK and contract on your project:

import { createThirdwebClient, getContract } from "thirdweb";
import { defineChain } from "thirdweb/chains";
// create the client with your clientId, or secretKey if in a server environment
const client = createThirdwebClient({
clientId: "YOUR_CLIENT_ID"
});
// connect to your contract
const contract = getContract({
client,
chain: defineChain(8453),
address: "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24"
});

You will need to pass a client ID/secret key to use thirdweb's infrastructure services. If you don't have any API keys yet you can create one for free from the dashboard settings.

All Functions & Events

import { prepareContractCall, sendTransaction } from "thirdweb";
const transaction = await prepareContractCall({
contract,
method: "function addLiquidity(address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline) returns (uint256 amountA, uint256 amountB, uint256 liquidity)",
params: [tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin, to, deadline]
});
const { transactionHash } = await sendTransaction({
transaction,
account
});