Skip to content

Instantly share code, notes, and snippets.

@rubinovitz
Created May 21, 2024 19:22
Show Gist options
  • Save rubinovitz/003a70f44bfe36c42d2ffcc04e6b0f51 to your computer and use it in GitHub Desktop.
Save rubinovitz/003a70f44bfe36c42d2ffcc04e6b0f51 to your computer and use it in GitHub Desktop.
import {encodeAbiParameters, getContract, parseAbiParameters, createWalletClient, custom} from 'viem';
import {contract1155ImplementationAbi} from '../abi/generated';
const FIXED_PRICE_SALE_STRATEGY = '0x1Cd1C1f3b8B779B50Db23155F2Cb244FCcA06B21';
const mint = async () => {
// embedded is the embedded wallet from useWallets
const provider = await embedded.getEthereumProvider();
const [account] = await provider.request({
method: "eth_requestAccounts",
});
const client = createWalletClient({
account,
transport: custom(provider),
chain: sepolia,
});
// contractId is the address of the proxy contract deployed from calling `createContract` on the parent contract
const contract = getContract({
address: data!.contractId,
abi: contract1155ImplementationAbi,
client: {
public: client,
wallet: client,
},
});
// quantity * (price + zora fee)
// we hardcoded all our tokens to 1000 gwei and all our quantities to 1
const value = 1n * (1000n + 777000000000000n);
const res = await contract.write.mintWithRewards(
[
FIXED_PRICE_SALE_STRATEGY,
BigInt(1),
BigInt(1),
encodeAbiParameters(parseAbiParameters('address, string'), [_client.account.address, '']),
client.account.address,
],
{value},
);
return res;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment