fbsobreira / gotron-sdk

Tron SDK for golang / CLI tool with keystore manager
GNU Lesser General Public License v3.0
322 stars 206 forks source link

please add the func (g *GrpcClient) TRC20TransferFrom #102

Open yangyile1990 opened 1 year ago

yangyile1990 commented 1 year ago

I use the sdk very happy. While when I used the TRC20Approve and finish my job. I cannot find the TRC20TransferFrom. and I don't know how to use it without your sdk. So. please implement the TRC20TransferFrom. Thank you.

daihaoxiaofei commented 1 year ago

tx, err := Client.TRC20Send(from, to, contractAddress, amount.BigInt(), FeeLimit)

alexchen01118 commented 1 year ago

tx, err := Client.TRC20Send(from, to, contractAddress, amount.BigInt(), FeeLimit)

this can't implement trc20TranferFrom

Flipped199 commented 11 months ago

Have you solved your problem? should I use TriggerContract?

robertchar92 commented 9 months ago

hi guys, did you guys have find solution to use transferFrom?

wxf4150 commented 8 months ago

https://github.com/fbsobreira/gotron-sdk/blob/1e824406fe8ce02f2fec4c96629d122560a3598f/pkg/client/trc20.go#L170-L179

ref above , i can get as trc20TranferFrom tx. it worked.

        addrA, err := address.Base58ToAddress(from)
    if err != nil {
        return nil, err
    }
    addrB, err := address.Base58ToAddress(to)
    if err != nil {
        return nil, err
    }
    contract := ueth.tokenAddressFromSymbol1(symbol, "TRON")

    amount :=big.NewInt(10000000) 
    ab := common.LeftPadBytes(amount.Bytes(), 32)
// 0x23b872dd is the erc20-transferFrom MethodSignature
    req := "0x23b872dd" +
        "0000000000000000000000000000000000000000000000000000000000000000"[len(addrA.Hex())-4:] + addrA.Hex()[4:] +
        "0000000000000000000000000000000000000000000000000000000000000000"[len(addrB.Hex())-4:] + addrB.Hex()[4:]
    req += common.Bytes2Hex(ab)

    //owner is who will sign the tx
    return Client.TRC20Call(owner, contract, req, false, 100000000)