SDK DOCS

Integrate OrisNFT private messaging into your app.

Setup

import { OrisSDK } from 'orisnft-sdk'

const sdk = new OrisSDK({
  contractAddress: '0x...your_deployed_contract...',
  apiBaseUrl: 'https://your-orisnft-app.com',
  rpcUrl: 'https://rpc.mainnet.chain.robinhood.com', // optional
})

createInbox()

Mint an inbox NFT and generate an encryption keypair. Requires a connected wallet.

const result = await sdk.createInbox(walletClient)

console.log('Inbox ID:', result.inboxId)
console.log('Tx Hash:', result.txHash)

// IMPORTANT: Back up the private key immediately!
// Losing it means losing access to all encrypted messages.
console.log('Private Key (PEM):', result.privateKeyPem)

const { publicKey, privateKey } = result.keyPair

⚠ The private key is generated in the browser and never sent to any server. Back it up immediately. Wallet recovery cannot restore encryption keys.

sendMessage()

Encrypt and send a message to any inbox. No wallet required.

const result = await sdk.sendMessage(
  1,                        // inbox ID
  'Hello from the SDK!',    // plaintext message
  '0xSenderAddress'         // optional sender address
)

console.log('Message ID:', result.id)
console.log('Sent at:', result.createdAt)

listMessages()

Fetch and decrypt messages for an inbox. Requires the private key.

const messages = await sdk.listMessages(
  1,                  // inbox ID
  privateKeyBase64    // base64-encoded private key
)

messages.forEach(msg => {
  if (msg.decryptionFailed) {
    console.log('Could not decrypt:', msg.id)
    return
  }
  console.log(`[${msg.createdAt}] ${msg.content}`)
})

Full Working Example

import { OrisSDK } from 'orisnft-sdk'
import { createWalletClient, custom } from 'viem'
import { robinhoodChain } from 'orisnft-sdk'

const sdk = new OrisSDK({
  contractAddress: '0x...deployed_contract...',
  apiBaseUrl: 'https://your-app.com',
})

// === ALICE: Create an inbox ===
const aliceWallet = createWalletClient({
  chain: robinhoodChain,
  transport: custom(window.ethereum!),
  account: aliceAddress,
})

const inbox = await sdk.createInbox(aliceWallet)
console.log('Alice inbox:', inbox.inboxId)
// Alice MUST save inbox.privateKeyPem

// === BOB: Send Alice a message ===
await sdk.sendMessage(inbox.inboxId, 'Hey Alice, encrypted!')

// === ALICE: Read her messages ===
const messages = await sdk.listMessages(
  inbox.inboxId,
  inbox.keyPair.privateKey
)
console.log(messages[0].content)
// => "Hey Alice, encrypted!"

Architecture

1.

Inbox NFT (ERC-721)

One nontransferable NFT per wallet on Robinhood Chain. Stores the owner's public encryption key onchain.

2.

Hybrid Encryption

RSA-OAEP 2048-bit for key exchange, AES-256-GCM for message content. All encryption happens in the browser.

3.

Ciphertext Storage

Only encrypted data stored on the server. The server never sees plaintext or private keys.

4.

Owner Decryption

Inbox owner decrypts in-browser using their private key stored locally in IndexedDB.

Security Notes

Message content is encrypted. Wallet addresses, inbox IDs, minting activity, and timestamps are publicly visible.

Private keys cannot be recovered. They are generated in-browser and never transmitted. Losing the key = permanently losing message access.

NFT ownership is verified before the app UI shows inbox data, but the real access control is the encryption — without the private key, ciphertext is unreadable.