NEWTON

NEWTON


Popular tags

    Cairo: How can i approve erc20 and transfer in the same transaction?

    Asked

    4 months ago

    25

    views


    0

    This question has a bounty of $0.00 in testnet ETH. Answers to this question are eligible to win that bounty.

    These are testnet contracts. Not real ETH.

    $0.00

    Looking to call the approve and transfer functions for an erc-20 in the same transaction. Thoughts on how to do this?

    This question was originally posted on Triality

      cairostarknet

    1 answers

    0

    Accepted answer

    You can make multicalls and batch many transactions that execute one after the other

    See the following code from @bowlsofchili in Telegram:

    export const constructTransaction = (contract, method, args = {}) => {

    

    const calldata = stark.compileCalldata(args);

    

    const transaction = {

    

    contractAddress: contract.address,

    

    entrypoint: method,

    

    calldata

    

    };

    

    return transaction

    

    };

    

    

    

    

    export const sendTransactions = async (transactions) => {

    

    try {

    

    return await getStarknet().account.execute(transactions);

    

    } catch (ex) {

    

    return Promise.reject(ex);

    

    }

    

    };

    see above, first method will help contruct individual txs and the second execute all of them at once

    This answer was originally posted on Triality

    answered

    4 months ago

    Answer is not submitted on chain

    Your answer

    NEWTON

    NEWTON