POST/track-and-trace/v1/jsonrpc
The JSON-RPC API provides methods assisting the construction of blockchain transactions and interaction with the ledger, i.e. write operation on ledger.
Request
- application/json
Bodyrequired
The body follows the JSON-RPC 2.0 specification.
It requires the following fields:
- jsonrpc: must be exactly "2.0"
- method: method to be invoked
- params: method parameters
- id: identifier established by the client
API Methods
authoriseDid
Requires an access token with tnt_authorise scope.
Call to build an unsigned transaction to authorise a DID to create documents.
Parameters:
- from: Ethereum address of the signer
- senderDid: DID of the signer. Must be a
did:ebsiDID (UTF-8) - authorisedDid: DID to authorise. Must be a
did:ebsiDID (UTF-8) registered in the DID Registry. - whiteList: Boolean to define if the DID is authorized or unauthorized
createDocument
Requires an access token with tnt_create scope.
Call to build an unsigned transaction to create a new Document.
By default, it records the timestamp of the blockchain, but it's possible to define a different timestamp with its respective proof.
Parameters:
- from: Ethereum address of the signer
- documentHash: Document hash
- documentMetadata: Document metadata as hex string
- didEbsiCreator: DID of the document creator. Must be a
did:ebsiDID (UTF-8) - timestamp (optional): Timestamp as hex string. By default it uses takes the timestamp from the blockchain
- timestampProof (optional): Timestamp proof as hex string. It must be defined when "timestamp" is defined
removeDocument
Requires an access token with tnt_write scope.
Call to build an unsigned transaction to remove a document and all related resources.
Parameters:
- from: Ethereum address of the signer
- documentHash: Document hash to remove
grantAccess
Requires an access token with tnt_write scope.
Call to build an unsigned transaction to grant a permission for a DID in a specific document.
"write" grant requires the transaction signer to be creator of the Document, or signer must have "delegate" permission in the Document. "delegate" grant requires the transaction signer to be creator of the Document.
Parameters:
- from: Ethereum address of the signer
- documentHash: Document hash
- grantedByAccount: Entity that grants the permission. If the entity uses the
did:ebsimethod,grantedByAccountmust be the UTF-8 DID encoded in hexadecimal. If the entity uses thedid:keymethod,grantedByAccountmust be the secp256k1 uncompressed public key (64 bytes or 65 bytes with 04 prefix) encoded in hexadecimal. - subjectAccount: Entity that receives the permission. If the entity uses the
did:ebsimethod,subjectAccountmust be the UTF-8 DID encoded in hexadecimal. If the entity uses thedid:keymethod,subjectAccountmust be the secp256k1 uncompressed public key (64 bytes or 65 bytes with 04 prefix) encoded in hexadecimal. - grantedByAccType: DID method of
grantedByAccount. Use0fordid:ebsior1fordid:key. - subjectAccType: DID method of
subjectAccount. Use0fordid:ebsior1fordid:key. - permission: Type of the permission to grant. Use
0for "delegate" or1for "write"
revokeAccess
Requires an access token with tnt_write scope.
Call to build an unsigned transaction to revoke a permission from a DID in a specific Document.
Keep in mind that whenever the document's creator private key is lost, then there is no possibility to revoke access for this creator's documents anymore.
Parameters:
- from: Ethereum address of the signer
- documentHash: Document hash
- revokedByAccount: Entity that revokes the permission. If the entity uses the
did:ebsimethod,revokedByAccountmust be the UTF-8 DID encoded in hexadecimal. If the entity uses thedid:keymethod,revokedByAccountmust be the secp256k1 uncompressed public key (64 bytes or 65 bytes with 04 prefix) encoded in hexadecimal. - subjectAccount: Entity whose permission is revoked. If the entity uses the
did:ebsimethod,subjectAccountmust be the UTF-8 DID encoded in hexadecimal. If the entity uses thedid:keymethod,subjectAccountmust be the secp256k1 uncompressed public key (64 bytes or 65 bytes with 04 prefix) encoded in hexadecimal. - permission: Type of the permission to revoke. Use
0for "delegate" or1for "write"
writeEvent
Requires an access token with tnt_write scope.
Call to build an unsigned transaction to write an event into a specific document.
By default, it records the timestamp of the blockchain, but it's possible to define a different timestamp with its respective proof.
Parameters:
- from: Ethereum address of the signer
- eventParams: Event parameters. JSON with the following fields:
- documentHash: Document hash (hex string)
- externalHash: External hash (string)
- sender: Entity that sends the event. If the entity uses the
did:ebsimethod,sendermust be the UTF-8 DID encoded in hexadecimal. If the entity uses thedid:keymethod,sendermust be the secp256k1 uncompressed public key (64 bytes or 65 bytes with 04 prefix) encoded in hexadecimal. - origin: Origin (string)
- metadata: Metadata (string)
- timestamp (optional): Timestamp as hex string. By default it uses takes the timestamp from the blockchain
- timestampProof (optional): Timestamp proof as hex string. It must be defined when "timestamp" is defined
sendSignedTransaction
Requires an access token with tnt_authorise, tnt_create or tnt_write scope.
Sends a signed transaction to the blockchain and returns the hash of the transaction.
Warning: the transaction is not immediately processed. Make sure to check that the transaction has been successfully included in a block before moving on.
You can get the receipt of the transaction by calling the eth_getTransactionReceipt method of Ledger API's Besu endpoint.
Receipts for pending transactions are not available, therefore you will have to wait until the transaction has been processed — usually a few seconds. We recommend you to poll the eth_getTransactionReceipt method until the receipt is available.
Once the receipt is available, you can check the status field to know if the transaction succeeded (0x1) or failed (0x0). If the transaction failed, the revertReason field will give you insights about the reason for the failure. You can learn more about the format of the revert reason in Besu's documentation.
Must be exactly "2.0"
Method that needs to be invoked
Array of parameters
Identifier established by the client
Responses
- 200
- 400
Response
- application/json
- Schema
- Build tx
- Send a transaction
Schema
- MOD2
Must be exactly "2.0"
Same identifier established by the client in the call
result object
Result of the call
{
"jsonrpc": "2.0",
"id": 482,
"result": {
"from": "0x8445fC96e27ceB0d1794be16a1Ac8BF5D765AACB",
"to": "0x823BBc0ceE3dE3B61AcfA0CEedb951AB9a013F05",
"data": "0x250f4d9700000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000120fb33cccb447605de75846617385f6d2aac28010f53a89ecb5ce151751c53c8d400000000000000000000000000000000000000000000000000000000000000206469643a656273693a7a5a766970744568464e31723275313868686937486f66000000000000000000000000000000000000000000000000000000000000000865794a68622e2e2e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000216469643a656273693a7a323536617342576d4842736a325a4e567847354d686b7000000000000000000000000000000000000000000000000000000000000000",
"value": "0x0",
"nonce": "0xb1d3",
"chainId": "0x181f",
"gasLimit": "0x1000000",
"gasPrice": "0x0"
}
}
{
"jsonrpc": "2.0",
"id": 1,
"result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}
Bad request
- application/problem+json
- Schema
- Bad Request
Schema
Default value: about:blank
An absolute URI that identifies the problem type. When dereferenced, it SHOULD provide human-readable documentation for the problem type.
A short summary of the problem type.
Possible values: >= 400 and <= 600
The HTTP status code generated by the origin server for this occurrence of the problem.
A human readable explanation specific to this occurrence of the problem.
An absolute URI that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.
{
"title": "Bad request",
"status": 400,
"detail": "Bad request"
}