InfraBlockchain / yosemite-public-blockchain

YOSEMITE Public Blockchain - General Purpose Public Blockchain for Business
https://yosemitex.com
Other
5 stars 1 forks source link

Delegated Transaction Fee Payment #106

Open bezalel opened 6 years ago

bezalel commented 6 years ago

The preset (on yx.txfee contract) transaction fee amount (in native stable token) is charged to the principal account of each transaction on YOSEMITE blockchain. But in real service situation, blockchain service provider can pay the transaction fees on behalf of service users. By paying user's blockchain transaction fee, service provider can enhance user experience and attract more customers.

To support 'Delegated Transaction Fee Payment', YOSEMITE blockchain provides 'transaction fee payer' option for every blockchain transaction. If 'transaction fee payer' field is specified in a submitted transaction, the transaction fee generated from the transaction is charged to the 'transaction fee payer'. The submitted transaction message must contain crypto signature of 'transaction fee payer' account.

bezalel commented 6 years ago

[clyos --fee-payer option support]

clyos push action yx.ntoken transfer '[ "useraccount3", "useraccount2", "5000.00 DKRW", "memo1" ]' -v producer.g --fee-payer useraccount2 -p useraccount3 -p useraccount2

executed transaction: 067f5d934ef47d2d016e0feaf66adb352146303a7567b23ddad5c2da62120387  184 bytes  1433 us
#     yx.ntoken <= yx.ntoken::transfer          {"from":"useraccount3","to":"useraccount2","amount":"5000.00 DKRW","memo":"memo1"}
#     yx.ntoken <= yx.ntoken::ntransfer         {"from":"useraccount3","to":"useraccount2","token":{"amount":"5000.00 DKRW","issuer":"sysdepo1"},"me...
#  useraccount3 <= yx.ntoken::ntransfer         {"from":"useraccount3","to":"useraccount2","token":{"amount":"5000.00 DKRW","issuer":"sysdepo1"},"me...
#  useraccount2 <= yx.ntoken::ntransfer         {"from":"useraccount3","to":"useraccount2","token":{"amount":"5000.00 DKRW","issuer":"sysdepo1"},"me...
#     yx.ntoken <= yx.ntoken::payfee            {"payer":"useraccount2","token":{"amount":"100.00 DKRW","issuer":"sysdepo1"}}
#  useraccount2 <= yx.ntoken::payfee            {"payer":"useraccount2","token":{"amount":"100.00 DKRW","issuer":"sysdepo1"}}
#      yx.txfee <= yx.ntoken::payfee            {"payer":"useraccount2","token":{"amount":"100.00 DKRW","issuer":"sysdepo1"}}
bezalel commented 6 years ago

[transaction message example]

#define YOSEMITE_DELEGATED_TRANSACTION_FEE_PAYER_TX_EXTENSION_FIELD 1002

clyos push action yx.ntoken transfer '[ "useraccount3", "useraccount2", "5000.00 DKRW", "memo1" ]' -v producer.g --fee-payer useraccount2 -p useraccount3 -p useraccount2 -j -d

{
  "expiration": "2018-10-17T09:03:24",
  "ref_block_num": 53886,
  "ref_block_prefix": 2554335991,
  "max_net_usage_words": 0,
  "max_cpu_usage_ms": 0,
  "delay_sec": 0,
  "context_free_actions": [],
  "actions": [{
      "account": "yx.ntoken",
      "name": "transfer",
      "authorization": [{
          "actor": "useraccount3",
          "permission": "active"
        },{
          "actor": "useraccount2",
          "permission": "active"
        }
      ],
      "data": "30f2d414217315d620f2d414217315d620a107000000000002444b5257000000056d656d6f31"
    }
  ],
  "transaction_extensions": [[
      1001,
      "00000357219de8ad"
    ],[
      1002,
      "20f2d414217315d6"
    ]
  ],
  "signatures": [
    "YSG_K1_K2RC4r9fM5PKUDDQ3EztyF6LTErparKi9mDyTK3VZfxMW7a7mLTFg7wJviPGZtmphXWUHeKBDr5ScChKouwzxP18t4iCGo",
    "YSG_K1_JyeRw5tf5sFyQ9d4pSNQzqGch7n3ULF8vm6kXTJvGPskJya4KNhh7sWpMbgz8fcs7WR6Bn9mrpmAtWJJPZ7JREgrZLWeiz"
  ],
  "context_free_data": []
}