Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Add decode function parameters #4917

Closed
2 tasks done
defido opened this issue Apr 4, 2022 · 7 comments · Fixed by #7345
Closed
2 tasks done

Add decode function parameters #4917

defido opened this issue Apr 4, 2022 · 7 comments · Fixed by #7345
Assignees
Labels

Comments

@defido
Copy link

defido commented Apr 4, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Feature Request

#3016

See here #3016 (comment)

In reference to the this problem people have, decoding a function requires removing the first 8 characters after the 0x.

Adding a decodeFunctionParameters method would solve this, simply by splicing the first 8 characters after the 0x and returning the parameters.

Use Cases

Used in getting the returned parameter data of function calls.

Stops people from being confused about why decodeParameters is not working.

Implementation Ideas

No response

Feature Examples/References

Ugly example, but it works to prove the point.

let web3 = new Web3('https://bsc-dataseed.binance.org/');
		const a = await web3.eth.getTransaction('0x041e65ab1b3ef192d1e2ae38d167f6293f026b20da980f4987e173c9ffcfc886');
		let find = a.input.slice(2, 10); <--- Slice the 8 characters out of the hex
		let remove = a.input.replace(find, ''); <--- Remove the 8 characters
		const z = await web3.eth.abi.decodeParameters(
			[
				{
					type: 'address',
					name: 'token',
				},
				{
					type: 'uint256',
					name: 'amount',
				},
				{
					type: 'address',
					name: 'receiverAddress',
				},
				{
					type: 'uint256',
					name: 'targetChainId',
				}
			],
			remove <--- Hex with function ID removed
		);
let remove = `0x${a.input.substr(10)}`; <---- Remove the function ID, add back in the 0x
		const z = await web3.eth.abi.decodeParameters(
			[
				{
					type: 'address',
					name: 'token',
				},
				{
					type: 'uint256',
					name: 'amount',
				},
				{
					type: 'address',
					name: 'receiverAddress',
				},
				{
					type: 'uint256',
					name: 'targetChainId',
				}
			],
			remove
		);

web3.eth.abi.decodeFunctionParameters([<PARAMETERS>], string)

Final output is CORRECT data.

Are you willing to implement this feature?

  • Yes
@defido defido changed the title Add decode function Add decode function parameters Apr 4, 2022
@jdevcs
Copy link
Contributor

jdevcs commented Apr 4, 2022

@defido Thanks, The best place to implement this will be our 4.x.

@nazarhussain nazarhussain added the 4.x 4.0 related label Apr 6, 2022
@nazarhussain
Copy link
Contributor

@defido Thanks for reaching out to us. I think that will be a nice feature but we will plan it for future releases in 4.x. You are welcomes to contribute this feature for 4.x branch.

@github-actions
Copy link

github-actions bot commented Jun 6, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

@github-actions github-actions bot added the Stale Has not received enough activity label Jun 6, 2022
@jdevcs jdevcs removed the Stale Has not received enough activity label Jun 16, 2022
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

@github-actions github-actions bot added the Stale Has not received enough activity label Aug 16, 2022
@jdevcs jdevcs removed the Stale Has not received enough activity label Aug 31, 2022
@jdevcs jdevcs reopened this Aug 31, 2022
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

@github-actions github-actions bot added the Stale Has not received enough activity label Oct 31, 2022
@mconnelly8 mconnelly8 removed the Stale Has not received enough activity label Nov 1, 2022
@github-actions
Copy link

github-actions bot commented Jan 1, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

@github-actions github-actions bot added the Stale Has not received enough activity label Jan 1, 2023
@jdevcs jdevcs removed the Stale Has not received enough activity label Jan 2, 2023
@github-actions
Copy link

github-actions bot commented Mar 4, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

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

Successfully merging a pull request may close this issue.

6 participants
@nazarhussain @Muhammad-Altabba @jdevcs @mconnelly8 @defido and others