Transfer ERC1155 Tokens
import 'dotenv/config';
import { NetworkNames, initializeSdkGateway } from '@kanalabs/mirai';
const collectionAddress = '0xc2132D05D31c914a87C6611C10748AEb04B58e8F'; // Sender address
const receiverAddress = '0x97a57d9CE2889E2E8DFb6019f8Eb51F5d119Bde3'; // Receiver address
(async () => {
// initializating sdk...
const sdk = await initializeSdkGateway(
{ privateKey: process.env.PRIVATE_KEY as string },
{
networks: [NetworkNames.Mumbai],
bundlerApiKey: process.env.BUNDLER_API_KEY
},
);
// set mumbai as default current instance
const networkInstance = sdk.setCurrentInstance(NetworkNames.Mumbai);
// get address of KanaWallet
const sender = await networkInstance.getCounterFactualAddress();
//initialize erc721 sdk instance
const erc1155 = sdk.erc1155(collectionAddress);
// clear any previous transactions in batch
await networkInstance.clearUserOpsFromBatch();
// add erc721 transferFrom function to the batch
await erc1155.safeTransferFrom(sender, receiverAddress, 1, 10, '0x');
// estimate transactions added to the batch and get the fee data for the UserOp
const op = await networkInstance.estimate();
// sign the UserOp and sending to the bundler...
const uoHash = await networkInstance.send(op);
// log the uoHash
console.log(`UserOpHash: ${uoHash}`);
})()
Last updated