mhw0/libethc

RPC responded Insufficient funds even if i have funds

mhw0 opened this issue ยท 33 comments

mhw0 commented

Discussed in #30

Originally posted by DerXanRam September 22, 2023
I'm trying to swap on Binance Smart Chain(which this library also works for it) using 1inch dex. But it says sometimes
"message":"insufficient funds for gas * price + value"
and some times
"message":"INTERNAL_ERROR: insufficient funds"

even if i have fund in my account to do the swap and cover the gas. all my balance is BNB and i'm swaping BNB(0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee) to BUSD(0xe9e7cea3dedca5984780bafc599bd69add087d56).

this are the values used in making the raw tnx

nonce=0x1
gasPrice is 0xd09dc300
GasLimit is 0x42c23
value is 0x2386f26fc10000
ToAddress is 0x1111111254eeb25477b68fb85ed929f73a960582

The ABI data is

0x12aa3caf000000000000000000000000f8a1527325bb62d6d0320eb2312748d590f1ce27000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000e9e7cea3dedca5984780bafc599bd69add087d56000000000000000000000000f8a1527325bb62d6d0320eb2312748d590f1ce27000000000000000000000000b438d71c1e6e8e53637e1f1dec37c2e635e335fc000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000001cfbbfaad4cc354a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016800000000000000000000000000000000000000000000000000014a00001a4041bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095cd0e30db05120830c9e0295730bbb220bd78346c6499ff37851fbbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00a4a5dcbcdf000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c000000000000000000000000e9e7cea3dedca5984780bafc599bd69add087d560000000000000000000000002c93437fa01c0123ed21e8b862762c887c1195130000000000000000000000001111111254eeb25477b68fb85ed929f73a960582ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008b1ccac8

and this is the raw tnx generated
f9036f0184d09dc30083042c23941111111254eeb25477b68fb85ed929f73a96058280b9030812aa3caf000000000000000000000000f8a1527325bb62d6d0320eb2312748d590f1ce27000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000e9e7cea3dedca5984780bafc599bd69add087d56000000000000000000000000f8a1527325bb62d6d0320eb2312748d590f1ce27000000000000000000000000b438d71c1e6e8e53637e1f1dec37c2e635e335fc000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000001cfbbfaad4cc354a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016800000000000000000000000000000000000000000000000000014a00001a4041bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095cd0e30db05120830c9e0295730bbb220bd78346c6499ff37851fbbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00a4a5dcbcdf000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c000000000000000000000000e9e7cea3dedca5984780bafc599bd69add087d560000000000000000000000002c93437fa01c0123ed21e8b862762c887c1195130000000000000000000000001111111254eeb25477b68fb85ed929f73a960582ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008b1ccac88193a0e67028be55afd7e2d967d969b1ca6ad19cc87b9a4157701c12704675fa21d560a06767242acafe600388c1909d0b599417f85937c0c069b9c6dddbf5075d070010

any encoding error ?Please help ๐Ÿ™

mhw0 commented

Hi @DerXanRam Have you checked your balance? or "gas * price + value" value?

Hello bro... i noticed i didin't encode the value...but even if i encoded the value and check the tnx on this site, value is still zero and through the previous error... take a look at the code

parameters are

nonce=0x1
gasPrice is 0xd09dc300
GasLimit is 0x42c23
value is 0x2386f26fc10000
ToAddress is 0x1111111254eeb25477b68fb85ed929f73a960582

The code snippet is

uint8_t nonce = 0x1, zero = 0x00, keccak[32], *rlp0bytes, *r, *s;
uint16_t chainid = 0x38;//56 BSC
		uint8_t v;
		size_t rlp0len, rlp1len, siglen = 32;

		ok(eth_rlp_init(&rlp0, ETH_RLP_ENCODE));
		ok(eth_rlp_array(&rlp0));
		ok(eth_rlp_uint8(&rlp0, &nonce));
		ok(eth_rlp_hex(&rlp0, &gasprice, NULL));
		ok(eth_rlp_hex(&rlp0, &gaslimit, NULL));
		ok(eth_rlp_address(&rlp0, &toaddr));
		ok(eth_rlp_hex(&rlp0, &value, NULL));
		ok(eth_rlp_uint8(&rlp0, &zero));
		ok(eth_rlp_hex(&rlp0, &abi_result, NULL));
		ok(eth_rlp_uint16(&rlp0, &chainid));
		ok(eth_rlp_uint8(&rlp0, &zero)); //   0x,
		ok(eth_rlp_uint8(&rlp0, &zero)); //   0x,
		ok(eth_rlp_array_end(&rlp0));	 // ]

		ok(eth_rlp_to_bytes(&rlp0bytes, &rlp0len, &rlp0));
		ok(eth_rlp_free(&rlp0));

		// compute the keccak hash of the encoded rlp elements
		ok(eth_keccak256(keccak, rlp0bytes, rlp0len));
		free(rlp0bytes);

		// sign the transaction
		ok(eth_ecdsa_sign(&sign, privkey, keccak));

		// calculate v
		v = sign.recid + chainid * 2 + 35;
		r = sign.r;
		s = sign.s;

		ok(eth_rlp_init(&rlp1, ETH_RLP_ENCODE));
		ok(eth_rlp_array(&rlp1));
		ok(eth_rlp_uint8(&rlp1, &nonce));
		ok(eth_rlp_hex(&rlp1, &gasprice, NULL));
		ok(eth_rlp_hex(&rlp1, &gaslimit, NULL));
		ok(eth_rlp_address(&rlp1, &toaddr));
		ok(eth_rlp_hex(&rlp0, &value, NULL));
		ok(eth_rlp_uint8(&rlp1, &zero));
		ok(eth_rlp_hex(&rlp1, &abi_result, NULL)); // replaced
		ok(eth_rlp_uint8(&rlp1, &v));
		ok(eth_rlp_bytes(&rlp1, &r, &siglen));
		ok(eth_rlp_bytes(&rlp1, &s, &siglen));
		ok(eth_rlp_array_end(&rlp1));

		// FIX3: this actually returns the output length
		ok(eth_rlp_to_hex(&txn, &rlp1) > 0);
		ok(eth_rlp_free(&rlp1));

the transaction generated is

f9036f0184d09dc3008303d852941111111254eeb25477b68fb85ed929f73a96058280b9030812aa3caf000000000000000000000000f8a1527325bb62d6d0320eb2312748d590f1ce27000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000e9e7cea3dedca5984780bafc599bd69add087d56000000000000000000000000f8a1527325bb62d6d0320eb2312748d590f1ce27000000000000000000000000b438d71c1e6e8e53637e1f1dec37c2e635e335fc000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000001d0ff12c059d97640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016800000000000000000000000000000000000000000000000000014a00001a4041bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095cd0e30db05120830c9e0295730bbb220bd78346c6499ff37851fbbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00a4a5dcbcdf000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c000000000000000000000000e9e7cea3dedca5984780bafc599bd69add087d560000000000000000000000002c93437fa01c0123ed21e8b862762c887c1195130000000000000000000000001111111254eeb25477b68fb85ed929f73a960582ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008b1ccac88193a0a3747216f490c13e87e39610337026e523826a5fe5ffba9394d3320ae03401dba0051a1e3ef7c16c8780ae3a876c6da107591ee2a6022bb79cd247e3b3593b03e7

Hi @DerXanRam Have you checked your balance? or "gas * price + value" value?

yeaa i have enough balance... i even do manual swap to check BNB is gas payment on BSC ๐Ÿ˜„ ... the gas fee are very small and i covered it($0.15)

mhw0 commented

Is 0xC4a13DA00881cBdaD2285e10aCe80dBF458aDd49 your address?

Is 0xC4a13DA00881cBdaD2285e10aCe80dBF458aDd49 your address?

No. It isn't my address

Is 0xC4a13DA00881cBdaD2285e10aCe80dBF458aDd49 your address?

And sorry for my late reply... it was midnight and i fall in a sleep

mhw0 commented

Okay, that's strange. This might be signature (v,r,s) issue.

mhw0 commented

any idea what can cause this?

Hello bro... i noticed i didin't encode the value...but even if i encoded the value and check the tnx on this site, value is still zero and through the previous error... take a look at the code

parameters are

nonce=0x1
gasPrice is 0xd09dc300
GasLimit is 0x42c23
value is 0x2386f26fc10000
ToAddress is 0x1111111254eeb25477b68fb85ed929f73a960582

The code snippet is

uint8_t nonce = 0x1, zero = 0x00, keccak[32], *rlp0bytes, *r, *s;
uint16_t chainid = 0x38;//56 BSC
		uint8_t v;
		size_t rlp0len, rlp1len, siglen = 32;

		ok(eth_rlp_init(&rlp0, ETH_RLP_ENCODE));
		ok(eth_rlp_array(&rlp0));
		ok(eth_rlp_uint8(&rlp0, &nonce));
		ok(eth_rlp_hex(&rlp0, &gasprice, NULL));
		ok(eth_rlp_hex(&rlp0, &gaslimit, NULL));
		ok(eth_rlp_address(&rlp0, &toaddr));
		ok(eth_rlp_hex(&rlp0, &value, NULL));
		ok(eth_rlp_uint8(&rlp0, &zero));
		ok(eth_rlp_hex(&rlp0, &abi_result, NULL));
		ok(eth_rlp_uint16(&rlp0, &chainid));
		ok(eth_rlp_uint8(&rlp0, &zero)); //   0x,
		ok(eth_rlp_uint8(&rlp0, &zero)); //   0x,
		ok(eth_rlp_array_end(&rlp0));	 // ]

		ok(eth_rlp_to_bytes(&rlp0bytes, &rlp0len, &rlp0));
		ok(eth_rlp_free(&rlp0));

		// compute the keccak hash of the encoded rlp elements
		ok(eth_keccak256(keccak, rlp0bytes, rlp0len));
		free(rlp0bytes);

		// sign the transaction
		ok(eth_ecdsa_sign(&sign, privkey, keccak));

		// calculate v
		v = sign.recid + chainid * 2 + 35;
		r = sign.r;
		s = sign.s;

		ok(eth_rlp_init(&rlp1, ETH_RLP_ENCODE));
		ok(eth_rlp_array(&rlp1));
		ok(eth_rlp_uint8(&rlp1, &nonce));
		ok(eth_rlp_hex(&rlp1, &gasprice, NULL));
		ok(eth_rlp_hex(&rlp1, &gaslimit, NULL));
		ok(eth_rlp_address(&rlp1, &toaddr));
		ok(eth_rlp_hex(&rlp0, &value, NULL));
		ok(eth_rlp_uint8(&rlp1, &zero));
		ok(eth_rlp_hex(&rlp1, &abi_result, NULL)); // replaced
		ok(eth_rlp_uint8(&rlp1, &v));
		ok(eth_rlp_bytes(&rlp1, &r, &siglen));
		ok(eth_rlp_bytes(&rlp1, &s, &siglen));
		ok(eth_rlp_array_end(&rlp1));

		// FIX3: this actually returns the output length
		ok(eth_rlp_to_hex(&txn, &rlp1) > 0);
		ok(eth_rlp_free(&rlp1));

the transaction generated is

f9036f0184d09dc3008303d852941111111254eeb25477b68fb85ed929f73a96058280b9030812aa3caf000000000000000000000000f8a1527325bb62d6d0320eb2312748d590f1ce27000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000e9e7cea3dedca5984780bafc599bd69add087d56000000000000000000000000f8a1527325bb62d6d0320eb2312748d590f1ce27000000000000000000000000b438d71c1e6e8e53637e1f1dec37c2e635e335fc000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000001d0ff12c059d97640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016800000000000000000000000000000000000000000000000000014a00001a4041bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095cd0e30db05120830c9e0295730bbb220bd78346c6499ff37851fbbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00a4a5dcbcdf000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c000000000000000000000000e9e7cea3dedca5984780bafc599bd69add087d560000000000000000000000002c93437fa01c0123ed21e8b862762c887c1195130000000000000000000000001111111254eeb25477b68fb85ed929f73a960582ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008b1ccac88193a0a3747216f490c13e87e39610337026e523826a5fe5ffba9394d3320ae03401dba0051a1e3ef7c16c8780ae3a876c6da107591ee2a6022bb79cd247e3b3593b03e7

I think i found the problem.... after calculating v, r, s i used rlp0 instead of rlp1. and aslo the zero value next to assigning value must be removed. After this i can see value when i decode the tnx hash.... but still the problem exist..... progressing

mhw0 commented

hopefully it's not secp256k1 deserialization issue

i hop...... I will close this isse... if it is related i will reopen it. Thanks for ur reply ๐Ÿ™

Hello bro ... after long try and error, also research.... i found that the rlp function has a bug, which it doesn't encode the tnx correctly.... u can see the previous tnx hashes and also the below one, my address is 0xb438D71c1E6E8E53637e1F1deC37c2E635e335fc but when u decode the transaction using this site the from address is not encoded correctly. i.e in the below tnx hash the address encoded is 0xC4a13DA00881cBdaD2285e10aCe80dBF458aDd49 but must be 0xb438D71c1E6E8E53637e1F1deC37c2E635e335fc .... i correctly added my private key like this (real account with no balance just to show how i pass the private key)

the private key from meta mask
803e53835193dd6ead61a25a745fa63586b4b2dd7b6abe4a06fa7f33c11aed81

in code

uint8_t privkey[] = {0x80, 0x3e, 0x53, 0x83, 0x51, 0x93, 0xdd, 0x6e,
			      0xad, 0x61, 0xa2, 0x5a, 0x74, 0x5f, 0xa6, 0x35,
			      0x86, 0xb4, 0xb2, 0xdd, 0x7b, 0x6a, 0xbe, 0x4a,
			      0x06, 0xfa, 0x7f, 0x33, 0xc1, 0x1a, 0xed, 0x81}; // real privare key of 0xa9d0a7dC416f586491f2fb596731598F937617b5

The tnx hash i'm trying to execute right now with xxxxxxxxxxxxxxxxx private key and account address 0xb438D71c1E6E8E53637e1F1deC37c2E635e335fc

the code .... i'm calling the approve() method to allow token spend for another address... so i set the value 0

uint16_t chainid = 0x38;//56 BSC
		uint8_t v;
		size_t rlp0len, rlp1len, siglen = 32;
        int ss=16;
		ok(eth_rlp_init(&rlp0, ETH_RLP_ENCODE));
		ok(eth_rlp_array(&rlp0));
		ok(eth_rlp_uint8(&rlp0, &nonce));
		ok(eth_rlp_hex(&rlp0, &gasprice, NULL));
		ok(eth_rlp_hex(&rlp0, &gaslimit, NULL));
		ok(eth_rlp_address(&rlp0, &toaddr));
		ok(eth_rlp_uint8(&rlp0, &zero));;
		ok(eth_rlp_hex(&rlp0, &abi_result, NULL));
		ok(eth_rlp_uint16(&rlp0, &chainid));
		ok(eth_rlp_uint8(&rlp0, &zero)); //   0x,
		ok(eth_rlp_uint8(&rlp0, &zero)); //   0x,
		ok(eth_rlp_array_end(&rlp0));	 // ]

		ok(eth_rlp_to_bytes(&rlp0bytes, &rlp0len, &rlp0));
		ok(eth_rlp_free(&rlp0));

		// compute the keccak hash of the encoded rlp elements
		ok(eth_keccak256(keccak, rlp0bytes, rlp0len));
		free(rlp0bytes);

		// sign the transaction
		ok(eth_ecdsa_sign(&sign, privkey, keccak));

		// calculate v
		v = sign.recid + chainid * 2 + 35;
		r = sign.r;
		s = sign.s;

		ok(eth_rlp_init(&rlp1, ETH_RLP_ENCODE));
		ok(eth_rlp_array(&rlp1));
		ok(eth_rlp_uint8(&rlp1, &nonce));
		ok(eth_rlp_hex(&rlp1, &gasprice, NULL));
		ok(eth_rlp_hex(&rlp1, &gaslimit, NULL));
		ok(eth_rlp_address(&rlp1, &toaddr));
		ok(eth_rlp_uint8(&rlp1, &zero));
		ok(eth_rlp_hex(&rlp1, &abi_result, NULL)); // replaced
		ok(eth_rlp_uint8(&rlp1, &v));
		ok(eth_rlp_bytes(&rlp1, &r, &siglen));
		ok(eth_rlp_bytes(&rlp1, &s, &siglen));
		ok(eth_rlp_array_end(&rlp1));

		// FIX3: this actually returns the output length
		ok(eth_rlp_to_hex(&txn, &rlp1) > 0);
		ok(eth_rlp_free(&rlp1));

the tnx hash generated

f8a90184d09dc3008203e894e9e7cea3dedca5984780bafc599bd69add087d5680b844095ea7b30000000000000000000000001111111254eeb25477b68fb85ed929f73a960582ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8194a07c7133d051ed0b253a8be58eef7c7ae632882d96c6161af30622af7569f7a181a029a9dc899f849e3b8bd94ba29368105b2e5b52002e274c8fd9a09318bbf7b5ae

please help ๐Ÿ™

mhw0 commented

Hey. Thanks for the detailed explanation. I'll need some time to fix this problem (just don't have free time right now). Thanks!

mhw0 commented

If you have a fix for this, do not hesitate to open a PR :)

Hey. Thanks for the detailed explanation. I'll need some time to fix this problem (just don't have free time right now). Thanks!

Ok thanks very much bro ๐Ÿ™ ... i hop u will fix it soon.... my entire project is highly depend on this lib ๐Ÿ˜„

If you have a fix for this, do not hesitate to open a PR :)

I' pretty new for blockchain programming... but i will try my best

mhw0 commented

Hello @DerXanRam Can you reproduce this error using hardhat?

Hello @DerXanRam Can you reproduce this error using hardhat?

I didn't use hardhat before....to replicate the error put some balance in ur wallet and try to send raw transaction (send token approval transaction...it costs only 4 or 5cents) and u can replicate the issue

mhw0 commented

Okay, let me actually test it on local node

mhw0 commented

I can't reproduce the error on local node. Are you sure that all the arguments are correct?

I can't reproduce the error on local node. Are you sure that all the arguments are correct?

yeaa... i try the same input on python code i found from the internet and the transaction works

mhw0 commented

I can't reproduce the error on local node. Are you sure that all the arguments are correct?

yeaa... i try the same input on python code i found from the internet and the transaction works

Can you please show me the whole code? (with the same secret and transaction arguments)

I can't reproduce the error on local node. Are you sure that all the arguments are correct?

yeaa... i try the same input on python code i found from the internet and the transaction works

Can you please show me the whole code? (with the same secret and transaction arguments)

ok....

Hello bro ... after long try and error, also research.... i found that the rlp function has a bug, which it doesn't encode the tnx correctly.... u can see the previous tnx hashes and also the below one, my address is 0xb438D71c1E6E8E53637e1F1deC37c2E635e335fc but when u decode the transaction using this site the from address is not encoded correctly. i.e in the below tnx hash the address encoded is 0xC4a13DA00881cBdaD2285e10aCe80dBF458aDd49 but must be 0xb438D71c1E6E8E53637e1F1deC37c2E635e335fc .... i correctly added my private key like this (real account with no balance just to show how i pass the private key)

the private key from meta mask 803e53835193dd6ead61a25a745fa63586b4b2dd7b6abe4a06fa7f33c11aed81

in code

uint8_t privkey[] = {0x80, 0x3e, 0x53, 0x83, 0x51, 0x93, 0xdd, 0x6e,
			      0xad, 0x61, 0xa2, 0x5a, 0x74, 0x5f, 0xa6, 0x35,
			      0x86, 0xb4, 0xb2, 0xdd, 0x7b, 0x6a, 0xbe, 0x4a,
			      0x06, 0xfa, 0x7f, 0x33, 0xc1, 0x1a, 0xed, 0x81}; // real privare key of 0xa9d0a7dC416f586491f2fb596731598F937617b5

The tnx hash i'm trying to execute right now with xxxxxxxxxxxxxxxxx private key and account address 0xb438D71c1E6E8E53637e1F1deC37c2E635e335fc

the code .... i'm calling the approve() method to allow token spend for another address... so i set the value 0

uint16_t chainid = 0x38;//56 BSC
		uint8_t v;
		size_t rlp0len, rlp1len, siglen = 32;
        int ss=16;
		ok(eth_rlp_init(&rlp0, ETH_RLP_ENCODE));
		ok(eth_rlp_array(&rlp0));
		ok(eth_rlp_uint8(&rlp0, &nonce));
		ok(eth_rlp_hex(&rlp0, &gasprice, NULL));
		ok(eth_rlp_hex(&rlp0, &gaslimit, NULL));
		ok(eth_rlp_address(&rlp0, &toaddr));
		ok(eth_rlp_uint8(&rlp0, &zero));;
		ok(eth_rlp_hex(&rlp0, &abi_result, NULL));
		ok(eth_rlp_uint16(&rlp0, &chainid));
		ok(eth_rlp_uint8(&rlp0, &zero)); //   0x,
		ok(eth_rlp_uint8(&rlp0, &zero)); //   0x,
		ok(eth_rlp_array_end(&rlp0));	 // ]

		ok(eth_rlp_to_bytes(&rlp0bytes, &rlp0len, &rlp0));
		ok(eth_rlp_free(&rlp0));

		// compute the keccak hash of the encoded rlp elements
		ok(eth_keccak256(keccak, rlp0bytes, rlp0len));
		free(rlp0bytes);

		// sign the transaction
		ok(eth_ecdsa_sign(&sign, privkey, keccak));

		// calculate v
		v = sign.recid + chainid * 2 + 35;
		r = sign.r;
		s = sign.s;

		ok(eth_rlp_init(&rlp1, ETH_RLP_ENCODE));
		ok(eth_rlp_array(&rlp1));
		ok(eth_rlp_uint8(&rlp1, &nonce));
		ok(eth_rlp_hex(&rlp1, &gasprice, NULL));
		ok(eth_rlp_hex(&rlp1, &gaslimit, NULL));
		ok(eth_rlp_address(&rlp1, &toaddr));
		ok(eth_rlp_uint8(&rlp1, &zero));
		ok(eth_rlp_hex(&rlp1, &abi_result, NULL)); // replaced
		ok(eth_rlp_uint8(&rlp1, &v));
		ok(eth_rlp_bytes(&rlp1, &r, &siglen));
		ok(eth_rlp_bytes(&rlp1, &s, &siglen));
		ok(eth_rlp_array_end(&rlp1));

		// FIX3: this actually returns the output length
		ok(eth_rlp_to_hex(&txn, &rlp1) > 0);
		ok(eth_rlp_free(&rlp1));

the tnx hash generated

f8a90184d09dc3008203e894e9e7cea3dedca5984780bafc599bd69add087d5680b844095ea7b30000000000000000000000001111111254eeb25477b68fb85ed929f73a960582ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8194a07c7133d051ed0b253a8be58eef7c7ae632882d96c6161af30622af7569f7a181a029a9dc899f849e3b8bd94ba29368105b2e5b52002e274c8fd9a09318bbf7b5ae

please help ๐Ÿ™

this is the code and test account PK and address... and I'm trying to send "approve" transaction

mhw0 commented

Yeah, but I can't see the nonce, gasprice, gaslimit etc.

Yeah, but I can't see the nonce, gasprice, gaslimit etc.

Sorry for my late replys... it is mid night and i fall in a sleep ๐Ÿ™

Yeah, but I can't see the nonce, gasprice, gaslimit etc.

Sorry for my late replys... it is mid night and i fall in a sleep ๐Ÿ™

I will send it tomorrow ... pls๐Ÿ™

{"data":"0x095ea7b30000000000000000000000001111111254eeb25477b68fb85ed929f73a960582ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","gasPrice":"3500000000","to":"0xbc7370641ddcf16a27eea11230af4a9f247b61f9","value":"0"}

i use gas=150000

mhw0 commented

Okay, I think I can't reproduce the issue as it's just "random" thing. Are you still getting this thing with that transaction? What if you remove the call part and tansfer some eth?

mhw0 commented

Oh, could you please try eth_keccak256p instead of eth_keccak256? Maybe prefix issue?

Okay, I think I can't reproduce the issue as it's just "random" thing. Are you still getting this thing with that transaction? What if you remove the call part and tansfer some eth?

ok i will try to transfer,,

Oh, could you please try eth_keccak256p instead of eth_keccak256? Maybe prefix issue?

Finally worked ๐Ÿ‘ by changing eth_keccak256 to eth_keccak256p >>> thanks a lot man ๐Ÿ™

mhw0 commented

Closing the issue. Thanks!