@avalanche-sdk/interchain
Version:
Interchain package for handling ICM/ICTT messages
26 lines • 951 B
JavaScript
import { createPublicClient, http } from "viem";
import { erc20ABI } from "../../abis/erc20ABI";
export async function deployERC20Token(walletClient, chain, name, symbol, initialSupply, recipient) {
const publicClient = createPublicClient({
chain,
transport: http(),
});
const txHash = await walletClient.deployContract({
abi: erc20ABI.abi,
bytecode: erc20ABI.bytecode,
args: [name, symbol, initialSupply * 10 ** 18, recipient],
chain,
account: walletClient.account ?? null,
});
const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
if (receipt.status === 'success' && receipt.contractAddress) {
return {
txHash,
contractAddress: receipt.contractAddress,
};
}
else {
throw new Error('Failed to deploy ERC20 token.', { cause: receipt });
}
}
//# sourceMappingURL=deployERC20Token.js.map