Demo
March 22, 2024 ยท View on GitHub
Prerequisites
- Compile and run the ISO-8583 chain as described in the README
- Have the ISO-8583 standard infrastructure mock running with
docker-compose
Insert keys to the keystore
To enable offchain worker, you need to insert your keys to the keystore. You can use the following command to do that:
curl -H "Content-Type: application/json" \
--data '{ "jsonrpc":"2.0", "method":"author_insertKey", "params":["'"iso8"'", "'"news slush supreme milk chapter athlete soap sausage put clutch what kitten"'", "'"0xd2bf4b844dfefd6772a8843e669f943408966a977e3ae2af1dd78e0f55f4df67"'"],"id":1 }' \
"http://localhost:9944"
Note that the above private key is used for demo purposes, i.e the trusted oracle and payment processor API expect this key to sign requests from offchain worker.
On-chain transfers
Usual Balances::transfer extrinsic and the whole balances pallet in general, is disabled. The only way to move funds between accounts is through ISO8583::initiate_transfer extrinsic. This is done to ensure that all transfers go through the payment processor as a ISO-8583 message.
Now, using either Charlie, Dave or Demo User, sign and submit initiate_transfer() extrinsic:
Heading back to the explorer, we will see:
And this will confirm the finality of the transfer, since it was processed by the bank, aka PCIDSS compliant oracle gateway.
On-chain reversals
One of the key points of ISO-8583, is that it gives the flexibility to reverse the transactions. ISO-8583 pallet implements ERC20R standard, enabling on-chain reversals, obviously not without the help from the oracle. Similar to transfer request, reversal is also triggered by an extrinsic. But before moving to the Extrinsics tab, make sure to copy hash value from the ProcessedTransaction event for previous transfer:
Fill the extrinsic form, sign and submit it:
Once it is submitted, Oracle picks up the event, transforms it to an ISO-8583 standard message and sends it to payment processor. After some due diligence, i.e
- only the sender of the transaction can reverse it
- transaction can be reversed only once
- there is some period after which it's not possible to reverse
Then, reversal request is either approved or ignored.
In our case, it is approved.
More ERC20R features
Pallet leverages a special feature of approvals, where unlimited approval from any account is given to the pallet's system account. This way we are able to handle reversals. However, approvals can also be used for normal users:
Here, Demo User gives an allowance of 10 UNITs to Charlie. Charlie then can transfer this to Dave:
There are two caveats with this feature right now:
- spender should at least have an ED. This is bit harder in our case, because issuance is controlled by the offchain ledger, but in the future it would be possible to implement paying for fees with the allowance.
- if
spenderinitiates transfer and for some reason that transfer is rejected by the oracle, allowance is decreased anyway. Sospenderneeds to be approved again if remaining allowance is not enough. This is due to finality of transfers being asynchronous.