GRPC client for the Provenance Blockchain

Tip: Refer to the Cosmos Proto Docs and
Provenance Blockchain Proto Docs for
client interface definitions.

Setup

Setup the client by supplying the chain id (e.g. pio-testnet-1) and URI of the node to which you are connecting. The normal GRPC port is 9090.

Example: for a locally running testnet instance:

val pbClient = PbClient("chain-local", URI("http://localhost:9090"))

Optionally configure GRPC by also passing ChannelOpts or a NettyChannelBuilder.

Example: Set client idle timeout to 1 minute

        val pbClient = PbClient(
            chainId = "chain-local",
            channelUri = URI("http://localhost:9090"),
            opts = ChannelOpts(idleTimeout = (1L to TimeUnit.MINUTES))
        )

Query Usage

PBClient contains individual clients for each Cosmos and Provenance Blockchain SDK query service. Each module contains a query.proto, which
defines the query interface.

Example: Querying the marker module for the access permissions on a marker:

Marker module query interface

pbClient.markerClient.access(QueryAccessRequest.newBuilder().setId("marker address or denom here").build())

Transaction Usage

Example: creating a Marker

val msgAddMarkerRequest: MsgAddMarkerRequest = // Your request here

val txn = TxOuterClass.TxBody.newBuilder()
    .addMessages(Any.pack(message = msgAddMarkerRequest, typeUrlPrefix = ""))
    .build()

val mySigner: Signer =  // Your key signing implementation

val signers = listOf(BaseReqSigner(key: mySigner))

pbClient.estimateAndBroadcastTx(
    txBody = txn,
    signers = signers,
    mode = ServiceOuterClass.BroadcastMode.BROADCAST_MODE_BLOCK,
    gasAdjustment = 1.5
)

Note: In general, BROADCAST_MODE_BLOCK is not recommended as your transaction may become successful past the time that
client blocks while waiting for the response. Instead use BROADCAST_MODE_SYNC, and listen for transaction success
in the Event Stream or query the client with the transaction hash to find the outcome of submission.

GitHub

View Github