Send data
Once you have your data prepared, you can send it to BLOOCK so it can be certified using our protocol.
When you send a new record to BLOOCK, it's queued internally and assigned to an Anchor. Once this Anchor is processed and transacted into the blockchain, the record gets certified and you will be able to verify it.
tip
The certification of a record may take some time to be confirmed. In order to manage this time interval, see Synchronization.
Examples
Here's a code example on how to send a set of Records to BLOOCK:
- Typescript
- Python
- Java
- PHP
- Golang
import { Bloock, IntegrityClient, RecordClient } from '@bloock/sdk';
try {
// we set the API key and create a client
Bloock.setApiKey(process.env['API_KEY']);
const integrityClient = new IntegrityClient();
const recordClient = new RecordClient();
// we create an array of strings which will contain
// the hashes of the records we want to send
const record = await recordClient.fromString('Hello world').build();
const records = [record];
// finally we can send the records
const sendReceipts = await integrityClient.sendRecords(records);
// we get a receipt with informationa about the transaction
console.log(sendReceipts);
} catch (e) {
console.log(e);
}
import os
import bloock
from bloock.client.record import RecordClient
from bloock.client.integrity import IntegrityClient
if __name__ == "__main__":
# we set the API key and create a client
bloock.api_key = os.environ["API_KEY"]
record_client = RecordClient()
integrity_client = IntegrityClient()
# we create an array of records which will contain
# the records we want to send
record = record_client.from_string("Hello world").build()
records = [record]
# finally we can send the records
send_receipts = integrity_client.send_records(records)
# we get a receipt with information about the transaction
print(list(map(lambda x: x.__dict__, send_receipts))) # pretty print receipts
import com.bloock.sdk.Bloock;
import com.bloock.sdk.client.IntegrityClient;
import com.bloock.sdk.client.RecordClient;
import com.bloock.sdk.entity.integrity.RecordReceipt;
import com.bloock.sdk.entity.record.Record;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Send {
public static void main(String[] args) throws Exception {
try {
// we set the API key and create a client
Bloock.apiKey = System.getenv("API_KEY");
RecordClient recordClient = new RecordClient();
IntegrityClient integrityClient = new IntegrityClient();
// we create an ArrayList of strings which will contain
// the hashes of the records we want to send
Record record = recordClient.fromString("Hello world").build();
ArrayList<Record> records = new ArrayList<>(Collections.singletonList(record));
// finally we can send the records
List<RecordReceipt> receipts = integrityClient.sendRecords(records);
// we get a receipt with informationa about the transaction
System.out.println(receipts);
} catch (Exception e) {
System.out.println(e);
}
}
}
<?php
require "./vendor/autoload.php";
use Bloock\Bloock;
use Bloock\Client\IntegrityClient;
use Bloock\Client\RecordClient;
Bloock::$apiKey = getenv("API_KEY") ?: "";
$integrityClient = new IntegrityClient();
$recordClient = new RecordClient();
$record = $recordClient->fromString("Hello world")->build();
$sendReceipts = $integrityClient->sendRecords([$record]);
package main
import (
"log"
"os"
bloock "github.com/bloock/bloock-sdk-go/v2"
"github.com/bloock/bloock-sdk-go/v2/client"
"github.com/bloock/bloock-sdk-go/v2/entity/record"
)
func main() {
// we set the API key and create a client
bloock.ApiKey = os.Getenv("API_KEY")
recordClient := client.NewRecordClient()
integrityClient := client.NewIntegrityClient()
// we create an array of strings which will contain
// the hashes of the records we want to send
r, err := recordClient.FromString("Hello world").Build()
if err != nil {
log.Println(err)
}
records := []record.Record{r}
// finally we can send the records
receipt, err := integrityClient.SendRecords(records)
if err != nil {
log.Println(err)
}
// we get a receipt with informationa about the transaction
log.Printf("%+v", receipt)
}