Quick Start

"Hello World!"

Let's use BWS.Blockchain.Save solution to write "Hello World!" to Sepolia blockchain.

You will learn how easy it is to interact with Blockchain[s] by using BWS!

Get your API key

Your API requests should be authenticated using your API key (any request that doesn't include an API key will return an error).

Learn how to Get your API Key.

Make your first request

We're going to use the BWS.Blockchain.Save solution and use the insertString operation to save "Hello Wolrd!" message to the blockchain.

Using BWS.Blockchain.Save to write "Hello World!" to Sepolia blockchain.

POST https://api.bws.ninja/v1/smart-contracts/call

Let's write "Hello World!" to the Sepolia blockchain network without having to manage network fees or accounts. Just by calling a regular Web2 API.

Request Body

{
    "statusCode": 200,
    "statusMessage": "",
    "info": {
        "jobId": "59d0f46b-0b58-4972-8aca-51d06f69f25e"
    }
}

Copy & Paste one of the following code snippets and run it (remember to use your own API Key).

curl --location 'https://api.bws.ninja/v1/smart-contracts/call' \
--header 'X-Api-Key: API-KEY' \
--header 'Content-Type: application/json' \
--data '{
    "solution": "BWS.Blockchain.Save",
    "version": 2,
    "network": "sepolia",
    "operation": "insertString",
    "parameters": {
        "key": "1689354473090",
        "value": "Hello World!"
    }
}'

If executed correctly, check for the jobId in the response body part. We will use it to verify that the blockchain operation has been correctly finished and get the blockchain transaction receipt.

Check for Results

To check for job completion and results, use the jobId you got from the previous call.

Please note interacting with blockchain(s) is asynchronous, so it may take some time for the operation to finish and get the blockchain receipt.

Fetch for the blockchain job status and results.

POST https://api.bws.ninja/v1/smart-contracts/fetch

Using the previous call response jobId we fetch blockchain job completion and the transaction details.

Request Body

{
    "statusCode": 200,
    "info": {
        "status": {
            "Value": "completed"
        },
        "request": {
            "contract": "Ethereum.Database.Immutable",
            "version": 2,
            "network": "mumbai",
            "operation": "insertBytes32",
            "parameters": {
                "key": "1689354473090",
                "value": "Hello World!"
            }
        },
        "hash": "0x0c24ce31e60dc55717cc7a848dbd4f26e2ea1575bd3560909cd49d033979c5dc",
        "txnUrl": "https://mumbai.polygonscan.com/tx/0x0c24ce31e60dc55717cc7a848dbd4f26e2ea1575bd3560909cd49d033979c5dc",
        "txnSnapshotUrl": "https://s3.amazonaws.com/bws-middleware-prod-website/tx/mumbai/0x0c24ce31e60dc55717cc7a848dbd4f26e2ea1575bd3560909cd49d033979c5dc.jpg",
        "receipt": {
            "blockHash": "0xd3ed53c1e45c85dcf0d779fa1c9d301a68790a53a99fd3be5b9b3225f63ebdc2",
            "blockNumber": 36761831,
            "contractAddress": null,
            "cumulativeGasUsed": 67833,
            "effectiveGasPrice": 400000000000,
            "from": "0x9089db83f0590ec2ed01a5eb4f8584dd6f4bdac7",
            "gasUsed": 67833,
            "logs": [
                {
                    "address": "0x0000000000000000000000000000000000001010",
                    "topics": [
                        "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63",
                        "0x0000000000000000000000000000000000000000000000000000000000001010",
                        "0x0000000000000000000000009089db83f0590ec2ed01a5eb4f8584dd6f4bdac7",
                        "0x000000000000000000000000be188d6641e8b680743a4815dfa0f6208038960f"
                    ],
                    "data": "0x000000000000000000000000000000000000000000000000006065806b8e107000000000000000000000000000000000000000000000000578958bee3ebc400000000000000000000000000000000000000000000000323e3b49fd5693557d050000000000000000000000000000000000000000000000057835266dd32e2f9000000000000000000000000000000000000000000000323e3baa62d6fee38d75",
                    "blockNumber": 36761831,
                    "transactionHash": "0x0c24ce31e60dc55717cc7a848dbd4f26e2ea1575bd3560909cd49d033979c5dc",
                    "transactionIndex": 0,
                    "blockHash": "0xd3ed53c1e45c85dcf0d779fa1c9d301a68790a53a99fd3be5b9b3225f63ebdc2",
                    "logIndex": 0,
                    "removed": false,
                    "id": "log_3576ed4a"
                }
            ],
            "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000010000000000000000000000000000800000000000000000000100000000004000000000000000000000000000000000000001000000000080000000000000000000000000000000000000000000000000000200000080000000000000000000200000000000000000000000000000000000000000000000000000000000004000000000000000000001000000000000000000000000000000100040000000000000000000000000000000000000000000000000000000000000000000100000",
            "status": true,
            "to": "0x58ca3f44cf5c84c1c29591a483be3288d0a01b7c",
            "transactionHash": "0x0c24ce31e60dc55717cc7a848dbd4f26e2ea1575bd3560909cd49d033979c5dc",
            "transactionIndex": 0,
            "type": "0x0"
        },
        "networkCost": 0.0,
        "networkFee": 0.0,
        "networkTotal": 0.0,
        "proofOfRegistryUrl": "https://prod.bws.ninja/tx.html?t=0x676b955edc5176cdb92f0084e48a06f84d12fa1044074742949b08453e53cb7a",
        "guid": "7e68bbfb-f26b-450b-8570-864c00564340",
        "type": {
            "value": "blockchain-job"
        },
        "timestampInMillis": 1686581426232
    }
}

Copy & Paste one of the following code snippets and run it (remember to use your own API Key).

curl --location 'https://api.bws.ninja/v1/fetch' \
--header 'X-Api-Key: API-KEY' \
--header 'Content-Type: application/json' \
--data '{
    "jobId": "59d0f46b-0b58-4512-8aca-51d06f69f25e"
}'

You should get a response indicating the job has been completed and the related blockchain receipt.

Congratulations! You used BWS to save data into the Web3 blockchain ecosystem.

Last updated