What you might not know about VeChainThor yet (Part III) — Transaction Fee Delegation (VIP-191)

How MPP works

Motivation behind VIP-191

enables a 3rd party, such as a dApp or a wallet, to pay for transaction fees on behalf of the sender, while still allowing the sender to maintain full control over their transaction signing and sending lifecycle.

How VIP-191 works

Comparison with MPP

Implementation of VIP-191

TX Model Extension

type reserved struct { 
Features Features
Unused []rlp.RawValue
}

Gas-Payer-Deciding Logic

if r.Delegator != nil { 
if energy.Sub(*r.Delegator, prepaid) {
return baseGasPrice, gasPrice, *r.Delegator, func(rgas uint64) { doReturnGas(rgas) }, nil
}
return nil, nil, thor.Address{}, nil, errors.New("insufficient energy")
}

Demo

A Walk-Through

Connex Interface for VIP-191

Results

-------------------------- 
VIP-191
--------------------------
TXID = 0xb58e1d1bf9da3414c24df51926003ebcbac7eb10246dd25548ccfd9202d4276e From = 0xd55100eedb61f1e553a38c33a234ce07952c43f2
To = 0x91436f1E5008B2E6093E114A25842F060012685d
GasPayer = 0xe4660c72dea1d9fc2a0dc2b3a42107d37edc6327
GasUsed = 21000
...
-------------------------- 
MPP - Add User
--------------------------
TXID = 0x508f50692c88054c5f8df982937b2871cae3cde002a4bc58e975277acca53c87 From = 0xe4660c72dea1d9fc2a0dc2b3a42107d37edc6327
To = 0x000000000000000000000050726f746f74797065
GasPayer = 0xe4660c72dea1d9fc2a0dc2b3a42107d37edc6327
GasUsed = 25074
...
--------------------------
MPP - Add Credit Plan
--------------------------
TXID = 0x57329507daadb47a8ea68375577f9699fce3f1329df4703451be36d3804aa853 From = 0xe4660c72dea1d9fc2a0dc2b3a42107d37edc6327
To = 0x000000000000000000000050726f746f74797065
GasPayer = 0xe4660c72dea1d9fc2a0dc2b3a42107d37edc6327
GasUsed = 44811
...
-------------------------- 
MPP - User Sends TX
--------------------------
TXID = 0x87b68a65105f2cc5746b88e1e0fd5e1cf4f6d2dbf8459bb8ef2599957ffcb655
From = 0xd55100eedb61f1e553a38c33a234ce07952c43f2
To = 0xe4660c72dea1d9fc2a0dc2b3a42107d37edc6327
GasPayer = 0xe4660c72dea1d9fc2a0dc2b3a42107d37edc6327
GasUsed = 21000

Previous Articles

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store