wpdas / kibi-blockchain

A project where I'm creating a kind of my own blockchain technology using Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kibi Blockchain Experiment

This is a project I created to simulate the operation of a Blockchain.

How to use

Download this repo, then, run cargo run;

Contract App

I've built an experimental Contract that uses Kibi Blockchain to store / read data. To use it, follow these steps:

  • 1 - Clone this repo and run cargo run;

  • 2 - Go to Kib GreetingContract repo and clone it;

  • 3 - Inside the kibi-greeting-contract repo/folder, run one of the commands below:

Persisting a greeting:

# dev-1234 = the contract id
# set_greeting = is a contract's method
# "Hello from Wendz!" = is the string value to be stored on chain under the contract
cargo run -- call dev-1234 set_greeting "Hello from Wendz!"

Viewing the current greeting:

# dev-1234 = the contract id
# greeting = is a contract's field
cargo run -- view dev-1234 greeting

Create Account

  • 1 - Run cargo run.

  • 2 - Execute the command bellow to create an account (change the account value as you wish):

curl --location 'http://localhost:8000/create_account' \
--header 'Content-Type: application/json' \
--data '{
    "account": "wendersonpires"
}'
  • 2 - Execute the command bellow to get the current chain data:
curl --location 'http://localhost:8000/chain'

You can navigate over the REST Api to get to know more.

REST Api

health check

URI: http://localhost:8000
METHOD: GET

new transaction

URI: http://localhost:8000/new_transaction
METHOD: POST
BODY:

{
  "from": "public key? user name?",
  "to": "<optional for now>",
  "content": "json content"
}

O body que é o dado de cada transação é salvo na chain em forma de String (stringified JSON).

create account

URI: http://localhost:8000/create_account
METHOD: POST
BODY: AUTO-MINE: true

{
  "account": "wendersonpires.kib"
}

Esta rota faz executa o mine automaticamente pois deve-se assegurar que uma conta igual não seja registrada novamente.

mine

URI: http://localhost:8000/mine
METHOD: GET

chain

URI: http://localhost:8000/chain
METHOD: GET

Durante o processo de buscar os blocos, todos os dados (transactions / dado) é convertido para JSON novamente para ser exibido ao cliente final.

contract transaction

URI: http://localhost:8000/contract_transaction
METHOD: POST
BODY:

{
  "tx_type": "CONTRACT",
  "contract_id": "dev-1234",
  "data": "stringified json content"
}

Rota usada para guardar novos dados em um contrato específico.

contract_payload

URI: http://localhost:8000/contract_payload/<contract_id>
METHOD: GET

Rota usada para buscar os dados mais atuais de um contrato.

contract_payload_json

URI: http://localhost:8000/contract_payload_json/<contract_id>
METHOD: GET

Rota usada para buscar os dados mais atuais de um contrato e retorna-los no formato JSON.

About

A project where I'm creating a kind of my own blockchain technology using Rust.


Languages

Language:Rust 100.0%