Other code (Backend and Middleware)

With the main meat of the Smart Contract discussed I'd like to point you at some interesting spots in the Backend and Middleware code.

Using neo-python-core to validate Blockchain key data.

By using the KeyPair class we created a quick and easy WIF validator for use during account registration. Is is really that simple! It even gives us the same error message.



Using neo-python-rpc to query our own or public nodes for smart contract data on the blockchain.

Information such as NEP5 Token name, symbol and decimals can be easily queried as shown below. Have a look at how this is done in the view and TokenInfo helper class. It's al documented :-)



Querying the blockchain using a slightly modified neo-python as Blockchain middleware running the experimental RPC server.

I've used neo-python as my starting point for the middleware. It has all the features from blockchain data parsing, to smart contract execution and notifications listening. It's almost a one stop shop. Have a look at the starting point here to see how all services are started. The RPC server is called JsonRpcApi and starts on Line 340.

Listening and reacting to live smart contract notification events happening on the blockchain.

Just being able to trigger events in smart contracts on the blockchain of course isn't enough. We want to be able to react to events created by our own smart contracts.We do this by listening to SmartContractEvents. The better_console.py listens to such events and pretty prints smart contract data that is Notified on the blockchain. I originally wrote it as an alternative for the default prompt.py output while developing and it turned out to be easy to adopt as a final event listener to push back data to the backend.

Dynamically calling other smart contracts on the blockchain from your own smart contract.

What's more fun than directly calling your own smart contract? Letting your smart contract call other smart contracts! This feature is described in the NEP4 standard for Dynamic Contract Invocation and has been recently introduced and implemented in both the C# and neo-python clients. I've used this extensively in the Event.py smart contract to trigger operations in NEP5 Tokens (such as transferFrom to move funds) as well as the Central Oracle. Have a look at how I used them here.

results matching ""

    No results matching ""