Skip to content

Bond protocol that runs on the computing layer of the sapphire OSL (Oasis Private Layer).

License

Notifications You must be signed in to change notification settings

dmigwi/dhamana-protocol

Repository files navigation

Contracts Tests GitHub tag License solidity - ^0.8.13 Go Reference

Dhamana Protocol

dhamana-protocol

Bond protocol that runs on the computing layer of the sapphire OSL (Oasis Private Layer).

Introduction

Dhamana is a swahili word with arabic origins that means "to offer guarantee". Dhamana-protocol is a system where people unknown to each other but vetted by Trust Organisations, engage in a discussion on how one of them will offer a (bond) security in exchange for financial support (Crypto/Fiat) on a project or an idea they are passionate about. The bond issuer, initiates the conversation by describing the principal, interest rate, security e.t.c.(bond details) with a view that one of the people interested will agree on their terms and subscribe to their bond. A trust organisation manages the critical user identity information on behalf of the protocol (DHP). The trustworthiness owned by the trust organisation is extended to the vetted users. Users don't have to know each other as long they trust the vetting organisation that allowed the other person into the platform. Trust is maintained by referals earned. The system allows people to make legal binding agreements that can be used to seek legal redress should one of the parties fall short of their expectations. Once the terms are agreed upon, financial transactions are done outside dhamana-protocol just as parties to the bond have agreed.

Table of Contents

Getting Started

=> Generate Chat contract ABI golang bindings

Step only necessary if you've modified the contracts functionality. The latest binds update are always uploaded online so no need to run this command if the original code is still intact. This go bindings enable the use of go-ethereum library when interacting with the deployed contracts.
  1. Download Abigen from Geth & Tools release for your platform. Extract the zipped file and abigen will be one of the zipped files.
  2. Install solc, the solidity compiler in one of the ways described here
  3. Confirm the two installation done above were successful by:
    • abigen
    $abigen --version
    abigen version 1.12.0-stable-e501b3b0
    
    • solc
    $ solc --version
    solc, the solidity compiler commandline interface
    Version: 0.8.21+commit.d9974bed.Linux.g++
    
  4. Generate ABI JSON file using:
    $ solc --abi contracts/chat.sol -o build --overwrite
    Compiler run successful. Artifact(s) can be found in directory "build".
    
  5. Generate Contract bindings in golang using
    $ abigen --abi ./build/ChatContract.abi --pkg contracts --type Chat --out client/contracts/chat.go
    

=> Contract Deployment

To deploy a contract; several networks are supported. They include development, sapphire_localnet, sapphire_testnet and sapphire_mainnet.

1. development network interacts with the raw ganache instance.
  • To deploy; install ganache then check for its installation. (Terminal Window 1)

    $ which ganache 
    ~/.nvm/versions/node/v18.0.0/bin/ganache 
    
  • Start up ganache:

    $ ganache
    ganache v7.9.0 (@ganache/cli: 0.10.0, @ganache/core: 0.10.0)
    Starting RPC server
    
    Available Accounts
    ==================
    (0) 0xcf7c8a3f10504Df1407088Ad9eFc6D0466645E73 (1000 ETH)
    (1) 0x696aE3BA64a757deE6039C848bA831697379d1C4 (1000 ETH)
    (2) 0xA21e897831A9D00F74bD9d72CbF17FeddA8E4845 (1000 ETH)
    ...
    
  • Run the contract deployment. It will deploy the contract, export the deployment log and generate go config bindings for the development network. (Terminal Window 2)

    $ pnpm run deploy_development     
    > dhamana-protocol@0.0.1 deploy_development ~/golang/src/github.com/dmigwi/dhamana-protocol
    > ./$npm_package_truffle migrate --network development --describe-json >> $npm_package_devlog && pnpm run gen_deployment_config $npm_package_devlog
    
    > dhamana-protocol@0.0.1 gen_deployment_config ~/golang/src/github.com/dmigwi/dhamana-protocol
    > go run ./deployInfo  "build/deploy_development.log"
    
    2023/08/21 00:12:40 Log deployment information has me written to : client/deployment/development/deployment.go
    
2. sapphire_localnet network interacts with a local deployment of the OASIS network.
  • To deploy install the backend by running a docker container. (Terminal Window 1)

    $ ./setup_localnet.sh 
    sapphire-dev 2023-07-10-gitbacd168 (oasis-core: 22.2.8, sapphire-paratime: 0.5.2, oasis-web3-gateway: 3.3.0-gitbacd168)
    
    Starting oasis-net-runner with sapphire...
    Starting postgresql...
    Starting oasis-web3-gateway...
    Bootstrapping network and populating account(s) (this might take a minute)...
    
    Available Accounts
    ==================
    (0) 0x9Bde9f59ef7b76A5283eB15F93f73aeD9aF044aF (1000 TEST)
    (1) 0xdf46bb474947756741dc1257ed0f54848606670D (1000 TEST)
    
    ...
    Private Keys
    ==================
    (0) 0xe32c076b6bafa297fa50d0a8dcee339edea7b52153bbe5860faa0f2424623ba4
    (1) 0xa87903873df7e7157010f341af7692326a54fa012e175bb0c91b5ed89395eb8b
    ...
    
  • Export the private key on the command line. This Private key will be from the account funding the contract deployment. (Terminal Window 2)

    export PRIVATE_KEY="0xe32c076b6bafa297fa50d0a8dcee339edea7b52153bbe5860faa0f2424623ba4"
    
  • Run the contract deployment. It will deploy the contract, export the deployment log and generate go config bindings for the sapphire_localnet network.

    $ pnpm run deploy_sapphire_localnet
    > dhamana-protocol@0.0.1 deploy_sapphire_localnet ~/golang/src/github.com/dmigwi/dhamana-protocol
    > ./$npm_package_truffle migrate --network sapphire_localnet --describe-json >> $npm_package_locallog && pnpm run gen_deployment_config $npm_package_locallog
    
    ⠏ Blocks: 0            Seconds: 0
    > dhamana-protocol@0.0.1 gen_deployment_config ~/golang/src/github.com/dmigwi/dhamana-protocol
    > go run ./deployInfo  "build/deploy_sapphire_localnet.log"
    
    2023/08/21 00:18:54 Log deployment information has me written to : client/deployment/sapphirelocalnet/deployment.go
    
3. sapphire_mainnet and sapphire_testnet networks deployments are way simpler, similar and straight forward. They interacts with the respective remote nodes of the OASIS network.
  • Export the respectve network private key on the command line. This Private key will be from the account funding the contract deployment. (Terminal Window 1)
    export PRIVATE_KEY="0xe.....4"
    
  • Run the contract deployment. It will deploy the contract, export the deployment log and generate go config bindings for the sapphire_testnet network.
    $ pnpm run deploy_sapphire_testnet 
    > dhamana-protocol@0.0.1 deploy_sapphire_testnet ~/golang/src/github.com/dmigwi/dhamana-protocol
    > ./$npm_package_truffle migrate --network sapphire_testnet --describe-json > $npm_package_testlog && pnpm run gen_deployment_config $npm_package_testlog
    
    ⠇ Blocks: 3            Seconds: 17
    > dhamana-protocol@0.0.1 gen_deployment_config ~/golang/src/github.com/dmigwi/dhamana-protocol
    > go run ./deployInfo  "build/deploy_sapphire_testnet.log"
    
    2023/08/21 00:26:04 Log deployment information has me written to : client/deployment/sapphiretestnet/deployment.go
    

=> Build Binary

Depending on the network you intend to run dhamana-protocol client on, deployment configuration with go bindings have already been generated at client/deployment/* path. The binary generated here will be tied to those binds. This implies that a single binary generated can interact with the same contract but running on different machine instances without the need of sharing the deployment logs.

  • Generate the binary called dhamana-protocol using.
    $ go build -o dhamana-protocol ./client
    
  • Initiate the server using:
    $  ./dhamana-protocol --network=sapphire_testnet
    2023-08-20 22:47:00.410 [INF] MAIN: Loading command configurations
    2023-08-20 22:47:00.411 [INF] MAIN: Using data directory: ~/.config/dhamana-protocol
    2023-08-20 22:47:00.411 [INF] SERVER: Running on the network: "SapphireTestnet"
    2023-08-20 22:47:00.411 [INF] SERVER: Deployed contract address found: "0x65043857F998FD9d7a910fCE23E692eBd1dc6878"
    2023-08-20 22:47:00.411 [INF] SERVER: Contract in use was deployed on Date: "Wed 05:36:49 2023-08-09"
    2023-08-20 22:47:00.411 [INF] SERVER: Contract in use was deployed on Tx: "0xbb502808fa8e30e49567f466f30cd300ce6b4759ec0d06e8fa16fa1f94816852"
    2023-08-20 22:47:00.411 [INF] SERVER: Creating a sapphire client wrapped over an eth client
    2023-08-20 22:47:02.364 [INF] SERVER: Initiating the server on: "https://0.0.0.0:30443"
    

And Dhamana Protocol is now live via https://0.0.0.0:30443

Features

  1. Truth Organisations

    • Their sole purpose is it to manage confidential user identifying information.
    • A single source of failure is eliminated because user information is stored in globally distributed locations.
    • Normal users will be less concerned with the identity of the person they interact with because of the trust of the vetting organisation.
    • Hacking the platform becomes extremely hard because trust has to be earned to access the DHAMANA PROTOCOL (DHP).
    • The more people who use the system as expected, the more trust is earned by the respective vetting organisations.
    • The vetting organisations get their trust penalised heavily for any malicious characters they vet and allow to join the platform.
  2. Double-Data Encryption

    • Communication between the PoAs (Point of Access) devices and the protocol backend is heavily encrypted. PoAs enable users to securely access the protocol.
    • User will require certificates signed by this trust organisation for them to connect to the system via TLS handshake.
    • Data shared after the handshake is further encrypted with the help of Diffie-Hellman key exchange and AES algorithms.
  3. Dispute Resolution Mechanism

    • Incase of a dispute the bond progress is halted until all parties to the bond arrive at a consensus.

Feedback

Acknowledgments

About

Bond protocol that runs on the computing layer of the sapphire OSL (Oasis Private Layer).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published