https://github.com/wpdas/kibi-blockchain
A project where I'm creating a kind of my own blockchain technology using Rust.
https://github.com/wpdas/kibi-blockchain
blockchain own rust-lang study
Last synced: 3 months ago
JSON representation
A project where I'm creating a kind of my own blockchain technology using Rust.
- Host: GitHub
- URL: https://github.com/wpdas/kibi-blockchain
- Owner: wpdas
- Created: 2023-07-01T08:23:23.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-08T07:36:03.000Z (almost 2 years ago)
- Last Synced: 2025-01-13T01:11:49.168Z (4 months ago)
- Topics: blockchain, own, rust-lang, study
- Language: Rust
- Homepage:
- Size: 266 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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`:
```sh
# 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`:
```sh
# 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):
```sh
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:
```sh
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:**```json
{
"from": "public key? user name?",
"to": "",
"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```json
{
"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:** GETDurante 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:**```json
{
"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/
**METHOD:** GETRota usada para buscar os dados mais atuais de um contrato.
### contract_payload_json
**URI:** http://localhost:8000/contract_payload_json/
**METHOD:** GETRota usada para buscar os dados mais atuais de um contrato e retorna-los no formato JSON.