TransferTokens

This function triggers a modal for the user to confirm the transfer

Description

Function to trigger a transfer for a native or ERC20 token. This will trigger a confirmation modal displaying a summary of the transaction and associated fees for the user.

Details

Signature

TransferTokens(args)

Arguments

Return Value

None

Example

Calling transfer without args

import { useMetafi } from '@metafi/react-sdk';

function App() {
    const { TransferTokens } = useMetafi();
    
    const transfer = () => {
        TransferTokens(res => console.log("received result from transfer", res));
    };

    return (
        <>
            <button onClick={transfer}>Transfer ETH</button>
        </>
    );
};

Calling transfer with args

import { useMetafi, assets } from '@metafi/react-sdk';

function App() {
    const { TransferTokens } = useMetafi();
    
    const transfer = () => {
        TransferTokens({
            userIdentifier: "12345",
            callback: (res) => {
                console.log("received result from transfer", res)
            },
            "to": "0xfFEaf294106b630d0cdD4afaAfe861563c72BB76",    // to
            "amount": "0.1",    // amount in display unit
            "currency": assets.eth,    // currency
        });
    };

    return (
        <>
           <button onClick={transfer}>Transfer ETH</button>
        </>
    );
};

Last updated