Links

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.
post
https://api.bws.ninja/v1
/smart-contracts/call
Using BWS.Blockchain.Save to write "Hello World!" to Sepolia blockchain.
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.
Parameters
Body
solution*
string
BWS.Blockchain.Save
version*
number
2
network*
string
sepolia
operation*
string
insertString
parameters*
JSON
{ key: "mykey",
value: "Hello World!"
}
Responses
200
Job created
Copy & Paste one of the following code snippets and run it (remember to use your own API Key).
curl
Javascript
Phyton
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!"
}
}'
var settings = {
"url": "https://api.bws.ninja/v1/call",
"method": "POST",
"timeout": 0,
"headers": {
"X-Api-Key": "API-KEY",
"Content-Type": "application/json"
},
"data": JSON.stringify({
"solution": "BWS.Blockchain.Save",
"version": 2,
"network": "sepolia",
"operation": "insertString",
"parameters": {
"key": "1689354473090",
"value": "Hello World!"
}
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
import http.client
import json
conn = http.client.HTTPSConnection("api.bws.ninja")
payload = json.dumps({
"solution": "BWS.Blockchain.Save",
"version": 2,
"network": "sepolia",
"operation": "insertString",
"parameters": {
"key": "1689354473090",
"value": "Hello World!"
}
})
headers = {
'X-Api-Key': 'API-KEY',
'Content-Type': 'application/json'
}
conn.request("POST", "/v1/call", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
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.
post
https://api.bws.ninja/v1
/smart-contracts/fetch
Fetch for the blockchain job status and results.
Using the previous call response jobId we fetch blockchain job completion and the transaction details.
Parameters
Body
jobId*
String
(use previously returned jobId, as for example 59d0f46b-0b58-4972-8aca-51d06f69f25e)
Responses
200: OK
Status and transaction receipt
Copy & Paste one of the following code snippets and run it (remember to use your own API Key).
curl
Javascript
Phyton
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"
}'
var settings = {
"url": "https://api.bws.ninja/v1/fetch",
"method": "POST",
"timeout": 0,
"headers": {
"X-Api-Key": "API-KEY",
"Content-Type": "application/json"
},
"data": JSON.stringify({
"jobId": "59d0f46b-0b58-4512-8aca-51d06f69f25e"
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
import http.client
import json
conn = http.client.HTTPSConnection("api.bws.ninja")
payload = json.dumps({
"jobId": "59d0f46b-0b58-4512-8aca-51d06f69f25e"
})
headers = {
'X-Api-Key': 'API-KEY',
'Content-Type': 'application/json'
}
conn.request("POST", "/v1/fetch", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
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.