SDK for React
The OKcontract SDK for React and Interactions Hub are designed to streamline the process of creating and managing smart contract interactions. Our tools provide developers with a platform to browse smart contracts, view smart contract ABIs, select methods, create and customize interactions, set parameters, and manage interactions lifecycle, including ownership and attestations.
Main Components
There are 4 main components that you can import into your React app:
Getting Started
Installation
To install the package, run the following command:
npm i --save @okcontract/sdk-react
Initialization
Initialize the SDK in your project by importing OKContract
, OKInstance
and OKInteraction
components into your React app.
import { OKContract, OKInstance, OKInteraction } from "@okcontract/sdk-react";
Create Smart Contract Interaction
To create a smart contract interaction, head to OKcontract Interactions Hub. You can browse smart contracts, view their ABIs, and choose methods and parameters to create your interactions on the hub. For testing purposes, you can use one of the existing interactions.
Interaction ID
Each interaction has its interactionID
that is automatically generated and is displayed on the interaction page, e.g. QOmvyY302kRJNSgyRrvW
.
Declare the interactionID
:
const interactionID = "QOmvyY302kRJNSgyRrvW";
And pass it as a parameter of OKInteraction
:
<OKContract>
<OKInstance>
<OKInteraction id={interactionID}>
...
</OKInteraction>
</OKInstance>
</OKContract>
GitHub Resources
- Check out the OKcontract SDK React GitHub repo.
- Start exploring by cloning the React demo app.