Use Fee Delegation
Fee Delegation Transaction is a service where the feePayer pays the fee for the transaction that the Sender wants to execute. This is done by adding the feePayer's signature to the existing transaction information signed by the Sender and sending it.
Fee Delegation Transaction only supports the DynamicFeeTxType among the existing transactions signed by the Sender and does not support LegacyTxType or AccessListTxType.
LegacyTxType
No
AccessListTxType
No
DynamicFeeTxType
Yes
Examples using CURL command
Firstly, create raw data of DynamicFeeTxType(0x02) transaction using personal_signTransaction method.
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"personal_signTransaction","params":[{"from":"0xc3e44aac2d0457942baffa1dc3be313bc8d65627","to":"0xdb8408bb47bf5e745fed00fc2c99e2f4e1a9270f","nonce":"0x1c","value":"0xDE0B6B3A7640000","maxPriorityFeePerGas":"0x174876E801","maxFeePerGas":"0x174876E801","gas":"0x5208"},""],"id":1}' http://127.0.0.1:8588
result: {"jsonrpc":"2.0","id":1,"result":{"raw":"0x02f8768204581c85174876e80185174876e80182520894db8408bb47bf5e745fed00fc2c99e2f4e1a9270f880de0b6b3a764000080c080a0b4dc96b4580bd1d3f090b953ea3612625dd834af8e7cc6146def84a0c137b32ca0082427bf3a4589ffe79bebad9151ece587790462cd44abdd810abe0016134b8f","tx":{"type":"0x2","nonce":"0x1c","gasPrice":null,"maxPriorityFeePerGas":"0x174876e801","maxFeePerGas":"0x174876e801","gas":"0x5208","value":"0xde0b6b3a7640000","input":"0x","v":"0x0","r":"0xb4dc96b4580bd1d3f090b953ea3612625dd834af8e7cc6146def84a0c137b32c","s":"0x82427bf3a4589ffe79bebad9151ece587790462cd44abdd810abe0016134b8f","to":"0xdb8408bb47bf5e745fed00fc2c99e2f4e1a9270f","chainId":"0x458","accessList":[],"hash":"0x80411634325036fe33e49104b1689f8d3ed92e2521ecfd058b26275b51471d70"}}}Secondly, create raw data of fee delegation transaction using personal_signRawFeeDelegateTransaction method (which is added to support fee delegation transaction).
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"personal_signRawFeeDelegateTransaction","params":[{"feePayer":"0xdb8408bb47bf5e745fed00fc2c99e2f4e1a9270f"},"0x02f8768204581c85174876e80185174876e80182520894db8408bb47bf5e745fed00fc2c99e2f4e1a9270f880de0b6b3a764000080c080a0b4dc96b4580bd1d3f090b953ea3612625dd834af8e7cc6146def84a0c137b32ca0082427bf3a4589ffe79bebad9151ece587790462cd44abdd810abe0016134b8f","test"],"id":1}' http://127.0.0.1:8588
result: {"jsonrpc":"2.0","id":1,"result":{"raw":"0x16f8d0f8768204581c85174876e80185174876e80182520894db8408bb47bf5e745fed00fc2c99e2f4e1a9270f880de0b6b3a764000080c080a0b4dc96b4580bd1d3f090b953ea3612625dd834af8e7cc6146def84a0c137b32ca0082427bf3a4589ffe79bebad9151ece587790462cd44abdd810abe0016134b8f94db8408bb47bf5e745fed00fc2c99e2f4e1a9270f80a0ba376dff9a2a4344a570367c94eeee2434a0e44ccf2da900f54becc6adaf0b5ca077b7d15ab7ba7213b5189094ca1bd41c7a48390767e4acb14c98f3442e561abb","tx":{"type":"0x17","nonce":"0x1c","gasPrice":null,"maxPriorityFeePerGas":"0x174876e801","maxFeePerGas":"0x174876e801","gas":"0x5208","value":"0xde0b6b3a7640000","input":"0x","v":"0x0","r":"0xb4dc96b4580bd1d3f090b953ea3612625dd834af8e7cc6146def84a0c137b32c","s":"0x82427bf3a4589ffe79bebad9151ece587790462cd44abdd810abe0016134b8f","to":"0xdb8408bb47bf5e745fed00fc2c99e2f4e1a9270f","chainId":"0x458","accessList":[],"hash":"0x19b5e90deb03cd4b87aca41ca09dcfed5e7c7ad33e6579f30f7efba722c54424","feePayer":"0xdb8408bb47bf5e745fed00fc2c99e2f4e1a9270f","fv":"0x0","fr":"0xba376dff9a2a4344a570367c94eeee2434a0e44ccf2da900f54becc6adaf0b5c","fs":"0x77b7d15ab7ba7213b5189094ca1bd41c7a48390767e4acb14c98f3442e561abb"}}}Finally, send signed fee delegation transaction to blockchain.
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0x17f8d0f8768204581c85174876e80185174876e80182520894db8408bb47bf5e745fed00fc2c99e2f4e1a9270f880de0b6b3a764000080c080a0b4dc96b4580bd1d3f090b953ea3612625dd834af8e7cc6146def84a0c137b32ca0082427bf3a4589ffe79bebad9151ece587790462cd44abdd810abe0016134b8f94db8408bb47bf5e745fed00fc2c99e2f4e1a9270f80a0ba376dff9a2a4344a570367c94eeee2434a0e44ccf2da900f54becc6adaf0b5ca077b7d15ab7ba7213b5189094ca1bd41c7a48390767e4acb14c98f3442e561abb"],"id":1}' http://127.0.0.1:8588
result: {"jsonrpc":"2.0","id":1,"result":"0x19b5e90deb03cd4b87aca41ca09dcfed5e7c7ad33e6579f30f7efba722c54424"}personal_signRawFeeDelegateTransaction method
parameters
result
Examples using gwemix console
Firstly, create raw data of DynamicFeeTxType(0x02) transaction using personal.signTransaction function.
Secondly, create raw data of fee delegation transaction using personal.signTransaction function (which is added to support fee delegation transaction).
Finally, send signed fee delegation transaction to blockchain using eth.sendRawTransaction function.
personal.signRawFeeDelegateTransaction() RPC
parameters
result
Examples using JavaScript
To send fee delegation transaction, we provide two utility modules (FeeDelegateDecode.js and FeeDelegateEncode.js). And these will need web3.js and ethereumjs-util.js libraries.
Firstly, install node js. https://nodejs.org/ko/download
Secondly, install web3.js and ethereumjs-util.js using npm.
Thirdly, save FeeDelegateDecode.js,FeeDelegateEncode.js and FeeDelegateSampleCode.js in same directory.
Finally, execute FeeDelegateSampleCode.js using node command.
Caution
You must prepare available wallet address and private key, and deposit corresponding amount of WEMIX in advance.
Please refer to the following for details.
sample code : FeeDelegateSampleCode.js
go-wemix : https://github.com/wemixarchive/go-wemix