Links
Comment on page
🥪

SDK

https://github.com/Othent/package
The Othent Library is a collection of functions that enable interaction with the Othent walletless protocol. These functions are designed to make it seamless for developers to integrate Othent into their applications.

Installation

To use the library in your project, you can install it using npm:
npm i othent

Usage

To use the library, you can import it into your project:
import { Othent } from 'othent';

Initialise Othent

You can generate your API ID from Othent.io
Receives an object with your API ID called API_ID.
// Initialise Othent
const othent = await Othent({
API_ID: 'YOUR API ID'
})

Functions

The following functions are available in the Othent Library:

Connect

ping

Ping the Othent server.
// Ping Othent
const response = await othent.ping();
console.log(response);

logIn

Log in a user and return their details.
// Log in / create account
const userDetails = await othent.logIn();
console.log(userDetails);
// for testnet, await othent.logIn({ testNet: true });

logOut

Log out the current user.
// Log out
const response = await othent.logOut();
console.log(response);

queryWalletAddressTxns

Query a Othent users wallet addresses transactions
// Query a users transactions
const walletAddress = 'Fqpw5BEnS1SCxwMJP4BhYCgzUmT8l3U6NNTBdjAXGF8'
const transactions = await othent.queryWalletAddressTxns({ walletAddress });
console.log(transactions);

userDetails

Retrieve the details of the current user.
// User details
const userDetails = await othent.userDetails();
console.log(userDetails);

Contracts

readContract

Read data from the current user's contract.
// Read contract
const contract = await othent.readContract();
console.log(contract);

readCustomContract

Read a custom contract by its contract_id. Receives an object with only one member of type string called contract_id
// Read custom contract
const contract_id = '2W9NoIJM1SuaFUaSOJsui_5lD_NvCHTjez5HKe2SjYU'
const contract = await othent.readCustomContract({contract_id});
console.log(contract);
// for testnet, add testNet: true to the readCustomContract function

viewCustomContract

View a custom contract by its contract_id. Receives an object with a function tags contract_id object
// View custom contract
const func = ''
const tags = [ { name: '', value: '' } ]
const contract_id = ''
const viewContractState = await othent.viewCustomContract({ function: func, tags, contract_id });
console.log(viewContractState);
// for testnet, add testNet: true to the readCustomContract function

Arweave Transactions

signTransactionArweave

Sign an Arweave transaction. It receives an object with 3 members:
  • othentFunction: action to be performed. Type string.
  • data: Data to be attached to the function.
  • tags: Array of objects with a { name: string, value: string} structure.
// Sign transaction Arweave
const signedArweaveTransaction = await othent.signTransactionArweave({
othentFunction: 'uploadData',
data: file,
tags: [ {name: 'Test', value: 'Tag'} ]
});
console.log(signedArweaveTransaction);

sendTransactionArweave

Send an Arweave transaction. Receives a signed Arweave transaction object like the one returned from the signTransactionArweave function above.
// Send transaction Arweave
const transaction = await othent.sendTransactionArweave(signedArweaveTransaction);
console.log(transaction)

verifyArweaveData

Verify a Arweave transaction. Receives a Arweave transaction id.
// Verify Bundlr transaction
const transactionId = 'Qi2K6IJY_VTlUJ3dszVm3Ot8UIOuMljMi8luw0ZdSnw'
const verifiedArweaveData = await othent.verifyArweaveData({ transactionId })
console.log(verifiedArweaveData)

Bundlr Transactions

signTransactionBundlr

Sign a Bundlr transaction. It receives an object with 3 members:
  • othentFunction: action to be performed. Type string.
  • data: Data to be attached to the function.
  • tags: Array of objects with a { name: string, value: string} structure.
// Sign transaction Bundlr
const signedBundlrTransaction = await othent.signTransactionBundlr({
othentFunction: 'uploadData',
data: file,
tags: [ {name: 'Test', value: 'Tag'} ]
});
console.log(signedBundlrTransaction);

sendTransactionBundlr

Send a Bundlr transaction. Receives a signed Bundlr transaction object like the one returned from the signTransactionBundlr function above.
// Send transaction Bundlr
const transaction = await othent.sendTransactionBundlr(signedBundlrTransaction);
console.log(transaction)

verifyBundlrData

Verify a Bundlr transaction. Receives a Bundlr transaction id.
// Verify Bundlr transaction
const transactionId = 'VpyBrjsQ9jlKSYda17T8Dua1P-SpbWfJvGz2V-UPvfk'
const verifiedBundlrData = await othent.verifyBundlrData({ transactionId })
console.log(verifiedBundlrData)

Warp Transactions

signTransactionWarp

Sign a Warp.cc transaction. It receives an object with 3 members:
  • othentFunction: action to be performed. Type string.
  • data: An object containing 3 members:
    • toContractid: A string with the Warp contract Id.
    • toContractFunction: A string with the function name from the Warp contract to call.
    • txnData: The data object that the mentioned function receives.
  • tags: Array of objects with a { name: string, value: string} structure.
// Sign transaction Warp
const signedWarpTransaction = await othent.signTransactionWarp({
othentFunction: 'sendTransaction',
data: {
toContractId: '2W9NoIJM1SuaFUaSOJsui_5lD_NvCHTjez5HKe2SjYU',
toContractFunction: 'createPost',
txnData: { blog_entry: 'Hello World!'}
},
tags: [ {name: 'Test', value: 'Tag'} ]
});
console.log(signedWarpTransaction);
// for testnet, simply add testNet: true to the signTransactionWarp function

sendTransactionWarp

Send a Warp transaction. Receives a signed Warp transaction object like the one returned from the signTransactionWarp function above.
// Send transaction Warp
const transaction = await othent.sendTransactionWarp(signedWarpTransaction);
console.log(transaction)

Utilities

initializeJWK

Backup an Othent account with a JWK private key. It receives a { JWK_public_key_PEM } object, the JWK PUBLIC key in PEM format!
// Initalize JWK to user
const transaction = await othent.initializeJWK({ JWK_public_key_PEM })
console.log(transaction);

JWKBackupTxn

Send a transaction with the specified JWK. It receives a { privateKey, sub, contract_id, tags, data, othentFunction } object.
// JWK backup transaction
// Note this function is only available in node, unless you use next.js or pollyfill the package from othent/node
const privateKey = {
"kty": "RSA",
"e": "AQAB",
"n": "iSGYBVYjH2jHL2ZfI3ymVWq-bqkPJUP3Zh8NzYrppU77RI-W_Gucg0ZMFHelgeY4xw2axhXWGJqLLFcp1Mr7xAZ3wIGLfiwvJNejFOwtJFcPbPoRKkTVLP0wWAZmbeKhnu1wFhfHrn2CYZEsVn2Z6BBUnXSo9CIG_Db55tfdcTM6gu6i9z_D3BUOhAeBeSKwqsc-G5KFG_r43I2tvVDpzWK8iUqTatRix0tvX1Mf1SLlovtEVBlNglmanTZdosZQyIxCS600ylCAaogWwYmh15PMz4Fw_pnkXpvTIGquOfVUoILxh7vbESsNknNKcrcD7uzrPyk7mBZeTDkjS-8avsTIDvibQGHznX_knAP2qiIHxjOmzp4jNRt7DphiIuXJZx5tm6kR7xOUcSiIxH4r0tiwWMiP95K1k7d9D8171CEn7YZmNJGYr4a-I8XML5vCq99SowksSoydi-UUN-hUNuiMLZKxi2EA_cI_DzX8WqzkLMHix6m8TQDRhUZ7otXiOXhloFWXV2KPiQD9WiioCcGUsGzUlRXxcpite5a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gP4JVMQJve3AYdjs-x_VZAZ4-v92YvNalx62gZFtYKaXinJB-IY1Kwr3-CyQ",
"qi": "Oyu3BdOZhTCSru1wlwV6ep2Fw7hHUp5ZQkyGALGUcXhLP2BKVyykrpEgeBxrQMt429LfGpaJ95waXD9SG92OxJMJCE84OORxez5yEQPepACfvAffqMcxvUiXehXDdSQ_V-vx53Mo_OuJ3D4b83pGtt38fZvERcZzaR32NOLen_GSFyEJVi9uxpB_oDGVKAMIsKb_5aSVx1kGb-xT8sR9wPbH2y0cXJQrhI-gtQ6x5OctOs4gJY8ZJOYDqiCgxm7QJMZ70AayJjXVqvQrqNeuBVyM1urFsV5Q1lg_CjYrtBPmBPwJ6e0SuSr40zH0Hr-Xw0RvNRreZNpLDZ-ard27yg"
}
const sub = 'google-oauth2|113378216876216346016'
const contract_id = 'JUTWhO3PF_22ras6JVIlCALzqlkfscKBKPz7vxYKXA8'
const tags = [ {name: 'Test', value: 'Tag'} ]
const data = {
toContractFunction: "createPost",
toContractId: "tQKJCf2E9lIaNTjM8ELK6ATlJtef8cVmq68c9XnVuj0",
txnData: {
POST: "TEST POST!"
}
}
const othentFunction = 'JWKBackupTxn'
const transaction = await othent.JWKBackupTxn({ privateKey, sub, contract_id, tags, data, othentFunction })
console.log(transaction)

encryptData

Encrypt data with a secret key. It receives a { data, key } object.
// Encrypt data
const data = 'I want this data encrypted!'
const key = 'password'
const encryptedData = await othent.encryptData({ data, key })
console.log(encryptedData)

decryptData

Decrypt data with a secret key. It receives a { data, key } object.
// Decrypt data
const data = 'U2FsdGVkX19sTWaZP0ST2zb7zvbTvvGU6lN0btbzGP3r13rSgZa8rgr4+XZG+yGX'
const key = 'password'
const decryptedData = await othent.decryptData({ data, key })
console.log(decryptedData)

deployWarpContract

Deploy a SmartWeave Warp.cc contract. It receives a { contractSrc, state, tags } object.
// Deploy contract
const fetchContract = await fetch('https://othent.io/contract-new.js')
const contract = fetchContract.text()
const state = { testState: 'testState' }
const tags = [ { name: 'testTag', value: 'testTag' } ]
const deployedContract = await othent.deployWarpContract({ contractSrc, state, tags })
console.log(deployedContract)
// for testnet, simply add testNet: true to the deployWarpContract function

deployWarpContractFromTx

Deploy a SmartWeave Warp.cc contract from a source transaction ID. It receives a { srcTxId, state, tags } object.
// Deploy contract from source transaction
const srcTxId = 'vnzoKP1yDyBvJsbLTQarhEzQ3RrD61noAx5w63nnAgU'
const state = { testState: 'testState' }
const tags = [ { name: 'testTag', value: 'testTag' } ]
const deployedContract = await othent.deployWarpContractFromTx({ srcTxId, state, tags })
console.log(deployedContract)
// for testnet, simply add testNet: true to the deployWarpContractFromTx function

Contact

If you have any questions or issues with the SDK, please contact us at [email protected] or open an issue in the GitHub repository at https://github.com/Othent.

License

The Othent Library is licensed under the MIT License. Please see the LICENSE file for more information.