Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yangyile1990 opened this issue Sep 9, 2023 · 5 comments
Open

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

yangyile1990 opened this issue Sep 9, 2023 · 5 comments

Comments

@yangyile1990
Copy link

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
Copy link

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

@alexchen01118
Copy link

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

this can't implement trc20TranferFrom

@Flipped199
Copy link

Have you solved your problem? should I use TriggerContract?

@robertchar92
Copy link

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

@wxf4150
Copy link

wxf4150 commented Jan 19, 2024

func (g *GrpcClient) TRC20Send(from, to, contract string, amount *big.Int, feeLimit int64) (*api.TransactionExtention, error) {
addrB, err := address.Base58ToAddress(to)
if err != nil {
return nil, err
}
ab := common.LeftPadBytes(amount.Bytes(), 32)
req := trc20TransferMethodSignature + "0000000000000000000000000000000000000000000000000000000000000000"[len(addrB.Hex())-4:] + addrB.Hex()[4:]
req += common.Bytes2Hex(ab)
return g.TRC20Call(from, contract, req, false, feeLimit)
}

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants