Banking on a Blockchain

19
Banking on a Blockchain Mark Simpson, Distinguished Engineer Innovation Engineering @ RBS

Transcript of Banking on a Blockchain

Banking on a BlockchainMark Simpson, Distinguished Engineer

Innovation Engineering @ RBS

Key points:How RBS is approaching Research and Innovation

What we have looked at in the distributed ledger space

Example - building a digital wallet on Hyperledger Fabric

What we’ve learnt about Hyperledger and other DLs.

The challenges we face as a bank and as blockchain developers

Some thoughts for the future

What is a code spike?

Identity a disruptive technology

Find a specific use case

Find some experienced engineers and give them four days

Build an MVP or fail fast

What distributed ledger technology have we looked at so far?

Could we build a digital wallet on blockchain?

Requirements for building a digital wallet

Move money from ‘real’ account to wallet

Make multiple transfers between accounts in wallet

Make payments out of the wallet to payment systems

Query wallet balances

Detect transaction errors

Query history of transactions

Obfuscate fields in transactions for certain users

Where to start?

use the example !!

https://github.com/hyperledger/fabric/tree/master/examples/chaincode/chaintool/example02/src/chaincode

Extending the contract for multiple transfers - complex types!

go - chain code

type Transfer struct {From string `json:"from"`To string `json:"to"`Amount float64 `json:"amount"`

}

type DigitalWalletBlockChainTransaction struct {Transfers []Transfer `json:"transfers"`RequestedAt string `json:"requestedAt"`Reference string `json:"reference"`Description string `json:"description"`Action string `json:"action"` // "action": "deposit | reserve | unreserve",Notes []string `json:"notes"` // "for reserve, the from is 'userid ' and to is 'userid-reserve'",

}

We can easily send complex types into the fabric from javascript//Build the payloadvar transferPayload ={ "transfers":[

{"from": "billy", "to": "greg", "amount": 1000.0 },{"from": "billy", "to": "mark", "amount": 1000.0 }

],"requestedAt": "2016-01-03T10:00:00.000Z","reference": "dispersals","description": “billy sends greg and mark some cash","action": "transfer","notes" : [“enables rollback of whole transaction on fail" ]

};

//Function to call itfunction transfer(transferpayload){

var request = require('request');

request({url: blockchainServer+'/devops/invoke', //URL to hitmethod: 'POST',json: {

"chaincodeSpec":{ "type": "GOLANG", "chaincodeID":{ "name":chainCodeStatic,},

"ctorMsg": {"function":"transfer","args":[transferpayload]

}etc….

Querying account balance is then quite easy

function queryit(account){

var request = require('request');

//Lets configure and requestrequest({

url: blockchainServer+'/devops/query', //URL to hitmethod: 'POST',//Lets post the following key/values as formjson: {

"chaincodeSpec":{"type": "GOLANG","chaincodeID":{"name":chainCodeStatic,

},"ctorMsg": {

"function":"query","args":[account]

}}}

What about Errors ??

You get an error if you send a bad payload or call an invalid chaincode

(back in February) Errors did not propagate out of chain code even if you returned an error. There was no error code on the transaction in the block

But, state is rolled back if your chain code returns error.

You can now detect transaction errors using the following code: https://github.com/hyperledger/fabric/tree/master/examples/events/block-listener

How did we do against our requirements?

Move ‘money’ from real account to wallet √

Make multiple transfers between accounts in wallet √

Make payments out of the wallet to payment systems √

Query wallet balances √

Detect transaction errors √ (nearly)

Query history of transactions X

Obfuscate some fields in transactions from certain users X

Transaction history - single version of the truth ?

https://github.com/hyperledger/fabric/wiki/Next-Ledger-Architecture-Proposal#pointintime

What did we learn?Writing and calling contracts is straight forward.

Asynchronicity is a challenge.

Maintaining a single version of the truth is a battle.

Tooling is work in progress.

Devops - interesting….

<devops?>

Working with R3

‘ There is only so much fun you can have with blockchain on your own’ - Richard Crook - head of innovation Engineering.

We are active members of the R3 group.

R3 gives us the ability to openly collaborate with other banks under non disclosure agreements.

key challengescollaborating with each other

security - data at rest

scalability

bad press / building understanding

contract safety

integrating ‘safely’ with the existing banking systems (http://bankofapis.com)

managing change

usability / consumerability

Some thoughts for the future

When will we see banks use ledgers in production?

Will contracts be used as legal language?

How de-centralised could the banking system become?

Why don’t google, facebook, amazon appear to be interested in blockchain?

Does blockchain give people the opportunity to secure their own personal data?

Could a blockchain be run entirely on mobile devices?

QUESTIONS ?