0.0.1-8 • Published 10 months ago

@uniblock/launcher-multisend v0.0.1-8

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@uniblock/launcher-multisend

This is a wrapper for the contract methods of Uniblock multiSend. Before you begin, please create a uniblock account and get a Uniblock api key here

1. Set up

Follow this step to add @uniblock/launcher-multisend to your repository:

npm i @uniblock/launcher-multisend

or

yarn add @uniblock/launcher-multisend

2. General Overview

Uniblock multiSend contract helps users to send crypto tokens, nfts or any other crypto assets in batch to other wallets. This package is created to simplify the usage of the multiSend contract. This makes the task of dealing with blockchain contracts easier for the developers. This means developers can call any contract methods in the same way as they call apis from their backend, thus allowing their applications to obtain the functionality of multiSend contract they deployed. For more details about this package, take a look at the documentation

3. Quick start

To initialize the SDK, you must first create a multisend contract through the Uniblock dashboard. Then you must provide a Uniblock API key which can be found after creating a project on the Uniblock site. The Uniblock API key can be seen on the project page. Then collect the contract address of your deployed contract and chain ID and pass them into the initialize function with the Uniblock API key:

import { initializeMultiSend } from "@uniblock/launcher-multisend"

const uniblockApiKey = <YOUR_UNIBLOCK_API_KEY>
const contractAddress = <YOUR_CONTRACT_ADDRESS>
const chainId = <YOUR_CHAIN_ID>
const option = {
    rpc: <YOUR_RPC_URL> // You can assign your own rpc url
}

const multiSendSdk = await initializeMultiSend(uniblockApiKey, {contractAddress, chainId}, option)
// or if you don't have your own rpc url, you can use uniblock sdk default url
// and use the following code:
// const multiSendSdk = await initializeMultiSend(uniblockApiKey, {contractAddress, chainId})

Note:

You can create your multiSend contract through the uniblock dashboard and get the contract address here

Get methods and Transfer methods

  • Get Transfer fee:

    • ERC20 fee:

      const erc20Fee = await multiSendSdk.getERC20Fee();
    • erc721 fee:

      const erc721Fee = await multiSend.getERC721Fee();
    • erc1155 fee:

      const erc1155Fee = await multiSend.getERC1155Fee();
    • Native fee:

      const nativeFee = await multiSend.getNativeFee();
  • Batch Transfer:

    • Before we use the transfer method, create a signer instance:

      • browser environment(we are using metamask in this example):

        const ethereum = (window as any).ethereum;
        const accounts = await ethereum.request({
          method: 'eth_requestAccounts',
        });
        
        const provider = new ethers.providers.Web3Provider(ethereum);
        const signer = provider.getSigner(accounts[0]);
      • Nodejs environment:

        const provider = new ethers.providers.JsonRpcProvider('RPC_URL', 5);
        const signer = new ethers.Wallet('WALLET_PRIVATE_KEY', provider);
    • batchTransferERC20:

      1. You need to allow MultiSend contract to transfer your payment tokens. You can do this by going to the etherscan to call the increaseAllowance by providing the spender address with this multiSend contract address if your presale contract is verified or run the following code:

        const allowance = 100 // set allowance to be 100 for example
        
        await multiSend.increaseAllowance(<ERC20_TOKEN_ADDRESS>, BigNumber.from(allowance), signer)
      1. Run the batchTransfer method:

        const tokenAddress = <ERC20_ADDRESS>
        const receivers = <WALLET_ADDRESS>
        const amount = 1
        const result = await multiSend.batchTransferERC20(tokenAddress, [receivers], [amount], signer)
    • batchTransferERC721:

      1. You need to approve MultiSend contract to transfer your nft tokens. You can do this by going to the etherscan to call approve by providing the to address with this multiSend contract address if your presale contract is verified or run the following code:

        // approve step:
        const tokenId = 1000 // set tokenId to be 1000 for example
        await multiSend.approve(<ERC721_TOKEN_ADDRESS>, BigNumber.from(tokenId), signer)
        
        // increaseAllowance for erc721 transfer fee:
        const amount = (await multiSendSdk.getFee())
        const feeToken = (await multiSendSdk.getPaymentToken())
        await multiSendSdk.increaseAllowance(feeToken, amount.toString(), signer)
      2. Run the batchTransfer method:

        const erc721Address = <ERC721_ADDRESS>
        const receivers = <WALLET_ADDRESS>
        const tokenId = 1
        const result = await multiSend.batchTransferERC721(erc721Address, [receivers], [tokenId], signer)
    • batchTransferERC1155:

      1. You need to approve MultiSend contract to transfer your nft tokens. You can do this by going to the etherscan to call setApprovalForAll by providing the to address with this multiSend contract address and setting approved to be true if your presale contract is verified or run the following code:

        // approve step:
        await multiSend.setApproveForAll(<ERC1155_TOKEN_ADDRESS>, true, signer)
        
        //increase allowance for erc1155 transfer fee
        const amount = (await multiSendSdk.getFee())
        const feeToken = (await multiSendSdk.getPaymentToken())
        await multiSendSdk.increaseAllowance(feeToken, amount.toString(), signer)
      2. Run the batchTransfer method:

         const erc1155Address = <ERC1155_ADDRESS>
        const receivers = <WALLET_ADDRESS>
        const tokenIds = [1]
        const amounts = [1]
        const data = ["0x0000000000000000000000000000000000000000"]
        const result = await multiSend.batchTransferERC1155(erc1155Address, receivers, [tokenIds], [amounts], data, signer)
    • batchTransferNative:

      const receivers = [<WALLLET_ADDRESS>]
      const amounts = [1]
      const result = await multiSend.batchTransferNative(receivers, amounts, signer)
0.0.1-8

10 months ago

0.0.1-7

12 months ago

0.0.1-6

12 months ago

0.0.1-5

1 year ago

0.0.1-4

1 year ago

0.0.1-3

1 year ago

0.0.1-2

1 year ago

0.0.1-1

1 year ago

0.0.1-0

1 year ago