diff --git a/app/components/Navbar.tsx b/app/components/Navbar.tsx index 54f3de8..73e54f6 100644 --- a/app/components/Navbar.tsx +++ b/app/components/Navbar.tsx @@ -51,11 +51,11 @@ export default function NavbarComponent() { ]; const sdkOptions = [ - { href: "/docs/typescript-sdk", label: "Typescript", subpath: '/', icons: }, { href: "/docs/react-sdk", label: "React", subpath: '/', icons: }, { href: "/docs/react-native-sdk", label: "React Native (Coming Soon)", subpath: '/', icons: }, { href: "/docs/flutter-sdk", label: "Flutter (Coming Soon)", subpath: '/', icons: }, { href: "/docs", label: "Unity (Coming Soon)", subpath: '/unity-sdk', icons: }, + { href: "/docs/typescript-sdk", label: "Typescript", subpath: '/', icons: }, ]; const getFrameworkLabel = () => { diff --git a/content/docs/meta.json b/content/docs/meta.json index acd41ea..5f1be59 100644 --- a/content/docs/meta.json +++ b/content/docs/meta.json @@ -9,11 +9,11 @@ "system-capabilities", "---SDK---", "okto-sdk", - "typescript-sdk", "react-sdk", "react-native-sdk", "flutter-sdk", "unity-sdk", + "typescript-sdk", "---Resources---", "developer-admin-dashboard", "brand-kit", diff --git a/content/docs/okto-sdk/feature-support.mdx b/content/docs/okto-sdk/feature-support.mdx index 7e1241b..ba4f503 100644 --- a/content/docs/okto-sdk/feature-support.mdx +++ b/content/docs/okto-sdk/feature-support.mdx @@ -11,11 +11,11 @@ Okto provides a seamless and secure way to integrate blockchain functionality in Okto offers a range of SDKs tailored to diverse development platforms, ensuring you have the right tools for your project: -- [**TypeScript**](/docs/typescript-sdk) – A TypeScript SDK for building Web3 applications. - [**React**](/docs/react-sdk) – A React library for integrating Okto into web applications. - [**React Native**](/docs/react-native-sdk) **(Coming Soon)** – A React Native SDK for mobile applications. - [**Flutter**](/docs/flutter-sdk) **(Coming Soon)** – A Flutter SDK for cross-platform applications. - [**Unity**](/docs/unity-sdk) **(Coming Soon)** – A Unity SDK for blockchain-based gaming apps. +- [**TypeScript**](/docs/typescript-sdk) – A TypeScript SDK for building Web3 applications. The Okto SDK supports multiple chains like **EVM, Solana and Aptos**, enabling seamless cross-chain interactions. diff --git a/content/docs/okto-sdk/index.mdx b/content/docs/okto-sdk/index.mdx index 5000c5f..63f601f 100644 --- a/content/docs/okto-sdk/index.mdx +++ b/content/docs/okto-sdk/index.mdx @@ -57,12 +57,6 @@ Get started with Okto SDK in just four steps: Pick the right SDK for your platform and start integrating Web3 features:
- } - title="TypeScript" - subtitle="for web" - link="/docs/typescript-sdk" - /> } @@ -85,6 +79,13 @@ Pick the right SDK for your platform and start integrating Web3 features: link="/docs/flutter-sdk" /> + } + title="TypeScript" + subtitle="for web" + link="/docs/typescript-sdk" + /> +
--- \ No newline at end of file diff --git a/content/docs/okto-sdk/supported-sdk-platforms.mdx b/content/docs/okto-sdk/supported-sdk-platforms.mdx index 311a9b6..b788b33 100644 --- a/content/docs/okto-sdk/supported-sdk-platforms.mdx +++ b/content/docs/okto-sdk/supported-sdk-platforms.mdx @@ -7,44 +7,7 @@ full: false import TechnologyCard from "app/components/mdx/TechnologyCard"; import { IoBookOutline, IoCodeSlashOutline, IoRocketOutline, IoAppsOutline } from "react-icons/io5"; -## 1. **Typescript SDK** -The Typescript SDK is designed for developers building Web3 applications with TypeScript. It simplifies blockchain interactions, enabling seamless onboarding and smooth user experiences. - -**Use Case**: Client-side web apps that don’t require a React-based solution - -
- } - title="Learn More" - subtitle="Explore Typescript SDK documentation" - link="/docs/typescript-sdk" - /> - - } - title="GitHub Repository" - subtitle="Access the source code" - link="https://github.com/okto-hq/okto-js-sdk-monorepo" - /> - - } - title="Quick Start Guide" - subtitle="Get up and running quickly" - link="/docs/typescript-sdk/quickstart" - /> - - } - title="Template App" - subtitle="Example implementation" - link="https://github.com/okto-hq/okto-sdkv2-ts-template" - /> -
- ---- - -## 2. **React SDK** +## 1. **React SDK** The React SDK is designed for developers building Web3 applications for the web. It simplifies blockchain interactions, enabling seamless onboarding and smooth user experiences. **Use Case**: Web applications @@ -61,7 +24,7 @@ The React SDK is designed for developers building Web3 applications for the web. icon={} title="GitHub Repository" subtitle="Access the source code" - link="https://github.com/okto-hq/okto-sdk-react" + link="https://github.com/okto-hq/okto-js-sdk-monorepo" /> } title="Template App" subtitle="Example implementation" - link="https://github.com/okto-hq/okto-sdk-react-template-app" + link="/docs/react-sdk/templateRepo" /> +The Okto TypeScript SDK is built exclusively for client-side (frontend) usage. Do not use this SDK in server-side applications or backend services. + + +
+ } + title="Learn More" + subtitle="Explore Typescript SDK documentation" + link="/docs/typescript-sdk" + /> + + } + title="GitHub Repository" + subtitle="Access the source code" + link="https://github.com/okto-hq/okto-js-sdk-monorepo" + /> + + } + title="Quick Start Guide" + subtitle="Get up and running quickly" + link="/docs/typescript-sdk/quickstart" + /> + + } + title="Template App" + subtitle="Example implementation" + link="https://github.com/okto-hq/okto-sdkv2-ts-template" + /> +
+ +--- + ## Get Started Today Pick your SDK and start building. diff --git a/content/docs/okto-sdk/use-cases.mdx b/content/docs/okto-sdk/use-cases.mdx index ecc4e25..7577aaa 100644 --- a/content/docs/okto-sdk/use-cases.mdx +++ b/content/docs/okto-sdk/use-cases.mdx @@ -142,7 +142,6 @@ You run an established Web2 service (e.g., e-commerce, a streaming platform, or 1. **Explore Our Docs:** - Check the [SDK Overview](/docs/sdk-overview) for a breakdown of each supported framework. - - Dive into the [API Reference](/api-docs) for details on methods like `transferTokens` and `transferNft`. 2. **Build a Proof of Concept:** - Use one of our [quickstart templates](https://github.com/okto-hq/okto-sdk-react-template-app) or read the [React Setup Guide](/docs/react-sdk/getting-started/new-okto-react-setup). - Experiment with a single chain or a single feature to see how Okto simplifies everything. diff --git a/content/docs/react-sdk/(Account)/meta.json b/content/docs/react-sdk/(Account)/meta.json index fe6ca33..d8cc1c0 100644 --- a/content/docs/react-sdk/(Account)/meta.json +++ b/content/docs/react-sdk/(Account)/meta.json @@ -1,6 +1,6 @@ { "title": "Account", "pages": [ - "estimate", "signUserOp" , "executeUserOp" + "userop-learn", "estimate", "signUserOp" , "executeUserOp" ] } \ No newline at end of file diff --git a/content/docs/react-sdk/(Account)/userop-learn.mdx b/content/docs/react-sdk/(Account)/userop-learn.mdx new file mode 100644 index 0000000..9e6ace8 --- /dev/null +++ b/content/docs/react-sdk/(Account)/userop-learn.mdx @@ -0,0 +1,75 @@ +--- +title: Understanding UserOp +description: Learn about User Operations (UserOp) in the context of Account Abstraction and the Okto SDK. +full: false +--- + +## What is a User Operation? + +User Operations (UserOps) are fundamental to [**ERC-4337 Account Abstraction**](https://eips.ethereum.org/EIPS/eip-4337). They are **pseudo-transaction objects** utilized for interacting with smart contract accounts. Unlike traditional transactions initiated by Externally Owned Accounts (EOAs), UserOps serve as structured instructions directed to a smart contract account to perform a blockchain action. Okto SDK provides tools to facilitate the creation, signing, and submission of UserOps. + +## How ERC-4337 Works + +ERC-4337 is the leading standard for account abstraction, enabling permissionless smart contract wallet functionality. The standard introduces several key components that work together to execute transactions: + +![ERC-4337 Flow Diagram](/images/erc4337-flow.png) + +The transaction flow works as follows: + +1. When a user wants to execute an action, they create a **User Operation** instead of a regular transaction. This structured object contains all necessary information about the intended transaction. + +2. The User Operation enters a special **mempool** where **Bundlers** (decentralized network participants) monitor for valid operations. Bundlers validate these operations and bundle them together for efficiency. + +3. The **Entry Point** contract serves as the central gateway, coordinating with the user's **Account** contract through two phases: + - First, it validates the operation's legitimacy through the validation loop + - Then, if valid, it executes the actual transaction data via the execution loop + +4. **Paymasters** can optionally sponsor gas fees, allowing for flexible payment arrangements and improved user experience. + +This architecture enables powerful features like batched transactions, sponsored gas fees, and custom validation logic while maintaining security and decentralization. + +## User Operation Structure + +In the traditional EOA model, transactions are signed and broadcast directly to the network. ERC-4337 introduces smart contract wallets and the concept of **UserOperation** to modify this process. Instead of directly sending transactions, users construct a **UserOperation**, a structured object detailing the intended action. + +The UserOperation object comprises specific fields that define transaction details and instructions for the smart contract account: + +| Field | Type | Description | +| :---------------------- | :-------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `sender` | `address` | The address of the smart contract account. This account is designated to initiate the action. | +| `nonce` | `uint256` | Anti-replay mechanism. Ensures each UserOperation is unique and cannot be replayed. Also functions as a salt for initial account deployment. | +| `initCode` | `bytes` | Code for deploying the smart contract account (`sender`) if it is not yet deployed on-chain. Relevant for the initial interaction with a new smart contract wallet. | +| `callData` | `bytes` | Encoded function call data and parameters intended for execution by the smart contract account (`sender`). Defines the action to be performed. | +| `callGasLimit` | `uint256` | Gas limit allocated for the execution phase of the `callData` within the smart contract account. | +| `verificationGasLimit` | `uint256` | Gas limit allocated for the verification phase of the UserOperation, encompassing signature checks and policy validations. | +| `preVerificationGas` | `uint256` | Gas units to compensate the Bundler for the overhead of UserOperation submission. Bundlers are responsible for upfront gas payment. | +| `maxFeePerGas` | `uint256` | Maximum fee per gas willing to be paid for the UserOperation, analogous to `maxFeePerGas` in EIP-1559 transactions. | +| `maxPriorityFeePerGas` | `uint256` | Maximum priority fee per gas willing to be paid, analogous to `maxPriorityFeePerGas` in EIP-1559 transactions. Incentivizes Bundler prioritization. | +| `paymasterAndData` | `bytes` | Optional field for Paymaster contract integration. Contains the Paymaster contract address and data required for verification and execution. Enables gas sponsorship scenarios. | +| `signature` | `bytes` | Cryptographic signature for UserOperation authorization. Validated during the verification phase by the EntryPoint contract. | + +Understanding the UserOperation structure is essential for working with ERC-4337 Account Abstraction. It provides a framework for executing actions via smart contract accounts. + +## Okto SDK Abstraction + +The Okto SDK simplifies working with UserOperations by abstracting away some of the more complex fields. Specifically, Okto often handles: + +* **Gas Limits:** `callGasLimit`, `verificationGasLimit` +* **Gas Fees:** `maxFeePerGas`, `maxPriorityFeePerGas` +* **Paymaster Interaction:** `paymasterAndData` (depending on client configuration) +* **PreVerification Gas:** `preVerificationGas` + +Okto SDK intelligently estimates and sets these values for you in most common scenarios, making it easier to create and execute UserOperations without needing to manually calculate all the gas parameters. However, for advanced use cases, you might still have the option to customize these fields. + +**With Okto SDK, developers primarily focus on specifying:** + +* `sender` address (Smart Account). +* `callData` (Function call and parameters). + +Okto SDK manages the construction of a valid UserOperation, including gas parameters and signature, to facilitate account abstraction implementation. + +## Learn More + +For a deeper dive into User Operations and the ERC-4337 standard, refer to the official documentation: + +[ERC-4337 User Operation Documentation](https://www.erc4337.io/docs/understanding-ERC-4337/user-operation) \ No newline at end of file diff --git a/content/docs/react-sdk/(Example Apps)/templateRepo.mdx b/content/docs/react-sdk/(Example Apps)/templateRepo.mdx index 895860e..50e5f5e 100644 --- a/content/docs/react-sdk/(Example Apps)/templateRepo.mdx +++ b/content/docs/react-sdk/(Example Apps)/templateRepo.mdx @@ -3,10 +3,70 @@ title: Template Repo full: false --- +A comprehensive walkthrough of the React Template app built using the Okto SDK. This template demonstrates core Okto functionality including authentication, wallet management, and blockchain interactions. + import { Callout } from 'fumadocs-ui/components/callout'; -Walkthrough for understanding the simple React Template app built using the Okto SDK. Check out the app [here](https://v2-react-sdk-sample-app.vercel.app/). +
+
+ Template Repository + +
+
+ +## Getting Started + +
+ Template App +
+ +1. Clone the repository: +```bash +git clone https://github.com/okto-hq/okto-sdkv2-react-template-app.git +``` + +2. Install dependencies: +```bash +cd okto-sdkv2-react-template-app +npm install +``` + +3. Set up environment variables: +```bash +cp .env.sample .env.local +``` + +4. Add your API keys to `.env.local`: +``` +VITE_VENDOR_PRIVATE_KEY="YOUR_VENDOR_PRIVATE_KEY" +VITE_VENDOR_SWA="YOUR_VENDOR_SWA" + +VITE_GOOGLE_CLIENT_SECRET="YOUR_GOOGLE_CLIENT_SECRET" +VITE_GOOGLE_CLIENT_ID="YOUR_GOOGLE_CLIENT_ID" +``` - - View the entire code in the Github repo [here](https://github.com/okto-hq/okto-sdkv2-react-template-app). - +5. Start the development server: +```bash +npm start +``` diff --git a/content/docs/react-sdk/(Explorer)/getAccount.mdx b/content/docs/react-sdk/(Explorer)/getAccount.mdx index 0436962..b398619 100644 --- a/content/docs/react-sdk/(Explorer)/getAccount.mdx +++ b/content/docs/react-sdk/(Explorer)/getAccount.mdx @@ -28,7 +28,9 @@ In Okto, an **account** represents the user's identity in the Okto ecosystem, en ### Parameters -There are no parameters for this function. It automatically fetches the accounts associated with the currently authenticated user. +| Parameter | Type | Description | +|-------------|-----------------------------|----------------------------------------| +| `oktoClient` | [`OktoClient`](/docs/react-sdk/technical-reference#models) | Okto client | ### Response @@ -40,27 +42,55 @@ There are no parameters for this function. It automatically fetches the accounts +### Example - + ```typescript - import { useOkto, type OktoContextType, type User} from 'okto-sdk-react'; - - const { getAccount } = useOkto() as OktoContextType; - - getAccount() - .then((result) => { - console.log(result) - }) - .catch((error) => { - console.error(`error:`, error); - }); + import { useOkto } from '@okto_web3/react-sdk'; + import { getAccount } from '@okto_web3/react-sdk'; + + function Account() { + const oktoClient = useOkto(); + + async function fetchAccount() { + try { + const account = await getAccount(oktoClient); + console.log('Account data:', account); + } catch (error) { + console.error('Error fetching user account:', error); + } + } + + return ( + + ); + } ``` + + +```json +{ + "status": "success", + "data": [ + { + "caip_id": "eip155:10", + "network_name": "OPTIMISM", + "address": "0x6698c56f99EaF4662cD70f974Cf787926e47781b", + "network_id": "f0620691-ce05-3d5c-94c7-1f2cf275c781", + "network_symbol": "OP" + } + ] +} +``` + \ No newline at end of file diff --git a/content/docs/react-sdk/(Explorer)/getChains.mdx b/content/docs/react-sdk/(Explorer)/getChains.mdx index befefa0..d7199cc 100644 --- a/content/docs/react-sdk/(Explorer)/getChains.mdx +++ b/content/docs/react-sdk/(Explorer)/getChains.mdx @@ -40,8 +40,10 @@ The `getChains` function retrieves a list of all blockchain networks supported b +### Example + - + ```typescript @@ -70,6 +72,66 @@ function ChainsList() { + + +```json +{ + "status": "success", + "data": { + "network": [ + { + "caip_id": "eip155:56", + "network_name": "BSC", + "chain_id": "56", + "logo": "BSC", + "sponsorship_enabled": true, + "gsn_enabled": false, + "type": "EVM", + "network_id": "9a26afcf-ed62-43d8-91ea-42dc7cd55890", + "onramp_enabled": false, + "whitelisted": true + }, + { + "caip_id": "eip155:42161", + "network_name": "ARBITRUM", + "chain_id": "42161", + "logo": "ARB", + "sponsorship_enabled": false, + "gsn_enabled": false, + "type": "EVM", + "network_id": "a003a74c-4dd2-3fc7-8c70-c080c9ca5afb", + "onramp_enabled": false, + "whitelisted": true + }, + { + "caip_id": "eip155:137", + "network_name": "POLYGON", + "chain_id": "137", + "logo": "POLYGON", + "sponsorship_enabled": true, + "gsn_enabled": false, + "type": "EVM", + "network_id": "ae506585-0ba7-32f3-8b92-120ddf940198", + "onramp_enabled": false, + "whitelisted": true + }, + { + "caip_id": "eip155:43114", + "network_name": "AVALANCHE", + "chain_id": "43114", + "logo": "AVAX", + "sponsorship_enabled": true, + "gsn_enabled": false, + "type": "EVM", + "network_id": "a3b96c4e-dc81-3c52-a9ee-729974ea74a0", + "onramp_enabled": false, + "whitelisted": true + } + ] + } +} +``` + \ No newline at end of file diff --git a/content/docs/react-sdk/(Explorer)/getOrderHistory.mdx b/content/docs/react-sdk/(Explorer)/getOrderHistory.mdx index deaf3f6..2d578cf 100644 --- a/content/docs/react-sdk/(Explorer)/getOrderHistory.mdx +++ b/content/docs/react-sdk/(Explorer)/getOrderHistory.mdx @@ -41,8 +41,10 @@ The `getOrdersHistory` function retrieves the list of orders for the authenticat +### Example + - + ```typescript @@ -71,6 +73,41 @@ function OrderHistory() { + + +```json +{ + "status": "success", + "data": { + "count": 1, + "items": [ + { + "downstream_transaction_hash": [ + "0xb30aacea6ee3883939255195172a62110b02aeb03dc590e0cd4d878995bc958b" + ], + "transaction_hash": [ + "0x1378f79faffa6ff1242c5d4ebdbc8fffc4bdbc44723cb63041d54fc67c671f97", + "0xd6f8416207f1589a600ce1c1a1b492b28f0ab5e9bcb499eb0886f886d4daed75" + ], + "status": "SUCCESSFUL", + "intent_id": "21260b29-2e72-4337-b494-c69d62dd3c92", + "intent_type": "TOKEN_TRANSFER", + "network_name": "OKTO_DEVNET", + "caip_id": "eip155:24879", + "details": { + "amount": "164060000", + "networkId": "eip155:137", + "recipientWalletAddress": "0x08a51013e6db8CE4594e0F9c0D13c96772d24336", + "tokenAddress": "" + }, + "reason": "", + "block_timestamp": 1738761051000 + } + ] + } +} +``` + \ No newline at end of file diff --git a/content/docs/react-sdk/(Explorer)/getPortfolio.mdx b/content/docs/react-sdk/(Explorer)/getPortfolio.mdx index dd4344d..992cead 100644 --- a/content/docs/react-sdk/(Explorer)/getPortfolio.mdx +++ b/content/docs/react-sdk/(Explorer)/getPortfolio.mdx @@ -40,8 +40,10 @@ The `getPortfolio` function retrieves the aggregated portfolio for the authentic +### Example + - + ```typescript @@ -70,6 +72,59 @@ function Portfolio() { + + +```json +{ + "status": "success", + "data": { + "aggregated_data": { + "holdings_count": "6", + "holdings_price_inr": "594.5431000000001", + "holdings_price_usdt": "8.821019999999999", + "total_holding_price_inr": "594.5431000000001", + "total_holding_price_usdt": "8.821019999999999" + }, + "group_tokens": [ + { + "id": "a9e192bb-bd18-3a47-ab07-5ecff29776e3", + "name": "Polygon Ecosystem Token", + "symbol": "POL", + "short_name": "POL", + "token_image": "https://www.dextools.io/resources/tokens/logos/3/ether/0x455e53cbb86018ac2b8092fdcd39d8444affc3f6.png?1698233684", + "token_address": "", + "group_id": "c885bfd2-abff-30d5-a0ba-aed6573a836d", + "network_id": "ae506585-0ba7-32f3-8b92-120ddf940198", + "precision": "4", + "network_name": "POLYGON", + "is_primary": false, + "balance": "3.7258", + "holdings_price_usdt": "1.14661", + "holdings_price_inr": "77.28166", + "aggregation_type": "group", + "tokens": [ + { + "id": "a9e192bb-bd18-3a47-ab07-5ecff29776e3", + "name": "Polygon Ecosystem Token", + "symbol": "POL", + "short_name": "POL", + "token_image": "https://www.dextools.io/resources/tokens/logos/3/ether/0x455e53cbb86018ac2b8092fdcd39d8444affc3f6.png?1698233684", + "token_address": "", + "network_id": "ae506585-0ba7-32f3-8b92-120ddf940198", + "precision": "4", + "network_name": "POLYGON", + "is_primary": true, + "balance": "3.7258", + "holdings_price_usdt": "1.14661", + "holdings_price_inr": "77.28166" + } + ] + } + ] + } +} +``` + \ No newline at end of file diff --git a/content/docs/react-sdk/(Explorer)/getPortfolioActivity.mdx b/content/docs/react-sdk/(Explorer)/getPortfolioActivity.mdx index 7f0fc71..728fb2b 100644 --- a/content/docs/react-sdk/(Explorer)/getPortfolioActivity.mdx +++ b/content/docs/react-sdk/(Explorer)/getPortfolioActivity.mdx @@ -40,8 +40,10 @@ The `getPortfolioActivity` function retrieves the portfolio activity for the aut +### Example + - + ```typescript @@ -70,6 +72,65 @@ function PortfolioActivity() { + + +```json +{ + "status": "success", + "data": { + "count": 50, + "activity": [ + { + "symbol": "", + "image": "", + "name": "", + "short_name": "", + "id": "", + "group_id": "", + "description": "NFT Deposit", + "quantity": "1.000000000000000000", + "amount": "", + "order_type": "EXTERNAL_TRANSFER", + "transfer_type": "DEPOSIT", + "status": true, + "created_at": 1739176632, + "updated_at": 1739176632, + "timestamp": 1739176632, + "tx_hash": "0x4e20af759a50080e548cc40f2504e569935ce0f3255bed9c9121e3fdaebc36d1", + "network_id": "ae506585-0ba7-32f3-8b92-120ddf940198", + "network_name": "POLYGON", + "network_explorer_url": "https://polygonscan.com/", + "network_symbol": "POLYGON", + "caip_id": "eip155:137" + }, + { + "symbol": "", + "image": "", + "name": "", + "short_name": "", + "id": "", + "group_id": "", + "description": "NFT Deposit", + "quantity": "1.000000000000000000", + "amount": "", + "order_type": "EXTERNAL_TRANSFER", + "transfer_type": "DEPOSIT", + "status": true, + "created_at": 1739170093, + "updated_at": 1739170093, + "timestamp": 1739170093, + "tx_hash": "0xba4eec0a5b1b1c6e4f741a94eb6350bffab0a2a822041ca69ccaee1c7978f0c8", + "network_id": "ae506585-0ba7-32f3-8b92-120ddf940198", + "network_name": "POLYGON", + "network_explorer_url": "https://polygonscan.com/", + "network_symbol": "POLYGON", + "caip_id": "eip155:137" + } + ] + } +} +``` + \ No newline at end of file diff --git a/content/docs/react-sdk/(Explorer)/getPortfolioNFT.mdx b/content/docs/react-sdk/(Explorer)/getPortfolioNFT.mdx index dcd73ed..a7596d7 100644 --- a/content/docs/react-sdk/(Explorer)/getPortfolioNFT.mdx +++ b/content/docs/react-sdk/(Explorer)/getPortfolioNFT.mdx @@ -40,8 +40,10 @@ The `getPortfolioNFT` function retrieves the list of NFTs in the authenticated u +### Example + - + ```typescript @@ -70,6 +72,34 @@ function NFTPortfolio() { + + +```json +{ + "status": "success", + "data": { + "count": 2, + "details": [ + { + "caip_id": "eip155:8453", + "network_name": "BASE", + "entity_type": "ERC721", + "collection_address": "0x19fc518b9eed93f70aa4b49133d303101699467a", + "collection_name": "MAYANKONBOARDINGTEST", + "nft_id": "5", + "image": "ipfs://QmWypyEUGo9mpt5R2EXbAwVRvtaAfg8TTyzwZEdDRowdov", + "quantity": "1.000000000000000000", + "token_uri": "https://ipfs.io/ipfs/QmT434r64HQXdkpKo5fRCCn2PzxmQQPtXgGSnrUVzpPwaw", + "description": "Marks a splashy start to your journey of conquering the ocean of web3 and achieving the ultimate feat of becoming a whale, metaphorically atleast ;)", + "nft_name": "Dolphin NFT - CoinDCX Maxis", + "explorer_smart_contract_url": "https://basescan.org/search?f=0&q=0x19fc518b9eed93f70aa4b49133d303101699467a", + "collection_image": "https://coindcx.s3.amazonaws.com/static/images/474c04b3-3abd-4d45-8cf4-f59871e15aec/Unfold_23.png" + } + ] + } +} +``` + \ No newline at end of file diff --git a/content/docs/react-sdk/(Explorer)/getTokens.mdx b/content/docs/react-sdk/(Explorer)/getTokens.mdx index fbe47bb..b8a1dac 100644 --- a/content/docs/react-sdk/(Explorer)/getTokens.mdx +++ b/content/docs/react-sdk/(Explorer)/getTokens.mdx @@ -40,8 +40,10 @@ The `getTokens` function fetches the list of supported tokens from the backend. +### Example + - + ```typescript @@ -70,6 +72,65 @@ function TokensList() { + + +```json +{ + "status": "success", + "data": [ + { + "caip_id": "eip155:10", + "network_name": "OPTIMISM", + "address": "0x6698c56f99EaF4662cD70f974Cf787926e47781b", + "network_id": "f0620691-ce05-3d5c-94c7-1f2cf275c781", + "network_symbol": "OP" + } + ] +} +``` + + +```json +{ + "status": "success", + "data": { + "count": 24, + "tokens": [ + { + "address": "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2", + "caip_id": "eip155:8453", + "symbol": "USDT", + "image": "https://images.okto.tech/token_logos/USDT.png", + "name": "", + "short_name": "Tether USD", + "id": "a060dd71-4ab2-3865-9530-5c4288f40506", + "group_id": "83e77d34-88e9-3e59-a678-231fbf336b08", + "is_primary": false, + "network_id": "9400de12-efc6-3e69-ab02-0eaf5aaf21e5", + "network_name": "BASE", + "onramp_enabled": false, + "whitelisted": true + }, + { + "address": "", + "caip_id": "eip155:56", + "symbol": "BNB", + "image": "https://images.okto.tech/token_logos/BNB.png", + "name": "BNB", + "short_name": "BNB", + "id": "d34383bb-b6b1-3d10-ad7f-60aef8d548fa", + "group_id": "9fc268f9-2a56-315a-bd6e-b6a91aceb79c", + "is_primary": true, + "network_id": "9a26afcf-ed62-43d8-91ea-42dc7cd55890", + "network_name": "BSC", + "onramp_enabled": false, + "whitelisted": true + } + ] + } +} +``` + \ No newline at end of file diff --git a/content/docs/react-sdk/authenticate-users/google-oauth/auth-user-via-code.mdx b/content/docs/react-sdk/authenticate-users/google-oauth/auth-user-via-code.mdx index d534780..e2f5f99 100644 --- a/content/docs/react-sdk/authenticate-users/google-oauth/auth-user-via-code.mdx +++ b/content/docs/react-sdk/authenticate-users/google-oauth/auth-user-via-code.mdx @@ -22,7 +22,7 @@ import "../../../styles.css"; ## Authenticate a User -async `authenticate(idToken, callback)` authenticates a user using an ID token. +async `authenticate(idToken, callback)` authenticates a user using an ID token. ### Parameters | Parameter | Type | Description | diff --git a/content/docs/react-sdk/index.mdx b/content/docs/react-sdk/index.mdx index 904bf61..6fe8275 100644 --- a/content/docs/react-sdk/index.mdx +++ b/content/docs/react-sdk/index.mdx @@ -12,15 +12,29 @@ import { IoCodeSlashOutline } from "react-icons/io5"; **Okto React SDK** is your all-in-one toolkit for integrating Web3 functionality into any React application. With minimal setup time, you can effortlessly onboard your users to the Web3 ecosystem and provide them with a seamless experience. -
+
} title="GitHub Repository" - subtitle="View Source Code" - link="https://github.com/okto-hq/okto-sdk-react" + subtitle="View SDK Source Code" + link="https://github.com/okto-hq/okto-js-sdk-monorepo" + /> + } + title="Template Repository" + subtitle="Example Implementation" + link="https://github.com/okto-hq/okto-sdkv2-react-template-app" />
+--- + +## Installation & Quickstart + +Kickstart your project by following our [Quickstart Guide](/docs/react-sdk/quickstart/new-okto-react-setup). This guide will take you through installing the SDK, configuring your project, and executing your first transaction. + +--- + ## Key Features - **Out-of-the-Box Chain Support** @@ -43,78 +57,53 @@ import { IoCodeSlashOutline } from "react-icons/io5"; --- -## Video Walkthrough - -
- -
- ---- - ## Navigating the React SDK Docs -Our documentation is organized to guide you through every stage of your development journey—from setting up the SDK to implementing advanced features. Below is an overview of the key sections and what they offer: +Our documentation is organized into several sections to help you at every stage of your development journey—from initial setup to advanced features. Here’s an updated overview of the main sections: ### 1. Getting Started - -Begin your journey by learning the essentials of setting up and configuring Okto within a new or existing React Native project. - -- [**Prerequisites**](./react-sdk/getting-started/prerequisites): Before you can begin, confirm you’ve got the necessary dependencies (Node, React, Okto API key) and set up your Google OAuth credentials if you’re using that flow. - -- [**Quickstart Guide**](./react-sdk/getting-started/new-okto-react-setup): A step-by-step walkthrough to install and initialize the SDK in less than 10 minutes. - ---- - -### 2. Using React Features - -Discover how to make the most of the Okto React SDK with prebuilt components and hooks that simplify common Web3 operations. - -- [**Components**](./react-sdk/using-react-features/components/OktoProvider): Set up the `OktoProvider` to initialize your app with all of Okto’s functionalities. - -- [**Hooks**](./react-sdk/using-react-features/hooks/useOkto): Access a host of capabilities—from token transfers to on-chain reads—through a single hook in any component. - ---- - -### 3. SDK Configurations - -Explore the capabilities of the Okto React SDK to maximize the potential of your Web3 application. From multi-chain support and user authentication to token management and smart contract interactions, this section provides a deep dive into features designed for scalability and customization. - -- [**Chains and Tokens**](./react-sdk/chains-tokens/supported-networks): Learn how to retrieve network and token information using the Okto SDK. - -- [**Authenticate Users**](./react-sdk/authenticate-users/google-oauth/learn): Implement authentication login flows, including Google OAuth, email OTP, and phone OTP. - -- [**Okto Embedded Wallet**](./react-sdk/okto-embedded-wallet/setup-embedded-wallets/create-embedded-wallets): Build a robust in-app wallet experience with multi-chain token/NFT support, raw transactions, and custom UI screens. ---- - -### 4. Example Apps - -Learn by example with practical implementations of the Okto React SDK. - -- [**Template App**](./react-sdk/example-apps/template-app): A fully working starter dApp that demonstrates best practices for integrating authentication, wallets, and multi-chain operations. -- [**Example Repos**](./react-sdk/example-apps/example-repos): Check out some of the example repos to see what others have been building using Okto. - ---- - -### 5. Troubleshooting & FAQ - -Find solutions to common issues, debug errors, and learn how to get help when needed. - -- [**Common Issues and Error Codes**](./react-sdk/troubleshooting-faq/sdk-error-warnings): A comprehensive list of errors, warnings, and their resolutions. -- [**Contact Us**](./react-sdk/troubleshooting-faq/contact-us): Reach out to our support team for personalized assistance or additional resources. +- [Quickstart Guide](/docs/react-sdk/quickstart/new-okto-react-setup): Learn how to create a new React app and integrate the Okto SDK in minutes. +- [Prerequisites](/docs/react-sdk/quickstart/prerequisites): A checklist of required dependencies, API keys, and initial setup steps. + +### 2. Authentication +Implement secure user login and session management: +- [Okto Auth](/docs/react-sdk/authenticate-users/okto-auth): Learn about authorization in Okto and Okto Auth Token +- [Google OAuth](/docs/react-sdk/authenticate-users/google-oauth/learn): Setup and authenticate users via Google. +- [Session Management](/docs/react-sdk/authenticate-users/login-logout): Manage user sessions and tokens. + +### 3. Wallets +Manage wallet functionality and customization: +- [Wallet Overview](/docs/react-sdk/wallets/overview): An introduction to wallet features within the SDK. +- [Embedded Wallets](/docs/react-sdk/wallets/(embedded-wallets)): Configure self-custodial wallets integrated into your app. +- [External Wallets](/docs/react-sdk/wallets/external-wallets) (Coming Soon): Integrate and manage third-party wallet solutions. + +### 4. Usage & Features +Explore the core capabilities of the SDK: +- [Usage Overview](/docs/react-sdk/usage-overview): A complete guide to using the Okto React SDK. +- [Hooks](/docs/react-sdk/(hooks)/useOkto): Leverage React hooks to tap into Okto functionality. +- [Account Operations](/docs/react-sdk/(Account)/estimate): Sign and execute user operations for on-chain actions. +- [Explorer Functions](/docs/react-sdk/(Explorer)/getAccount): Retrieve account details, supported chains, tokens, and portfolio data. +- [Intent Operations](/docs/react-sdk/(Intents)/…): Create and manage blockchain transactions such as token or NFT transfers. + +### 5. Resources +Access additional reference materials and support: +- [Technical Reference](/docs/react-sdk/technical-reference): In-depth documentation of classes, methods, and data models. +- [SDK Error Warnings](/docs/react-sdk/sdk-error-warnings): A list of common error messages and troubleshooting tips. +- [Troubleshooting](/docs/react-sdk/troubleshooting): Guidance on resolving common issues. +- [Changelog](/docs/react-sdk/changelog): Detailed release notes and updates. +- [Feature Support](/docs/react-sdk/feature-support): Information on supported chains, tokens, and additional functionalities. +- [Example Apps](/docs/react-sdk/(Example Apps)/template-app): Sample projects showcasing best practices with the SDK. + +### 6. Migration +- [V2 Migration Guide](/docs/react-sdk/v2migration) (Coming Soon): Instructions and tips for upgrading from previous versions of the SDK. --- ## Get Started -Ready to dive in? We recommend you begin with our **[Getting Started guide](./react-sdk/getting-started/new-okto-react-setup)** to set up your environment, get your Okto API key, and spin up a simple React app. Once you’re comfortable with the basics, feel free to explore more advanced features or check out our example apps. +Ready to dive in? We recommend you begin with our **[Getting Started guide](./react-sdk/quickstart/new-okto-react-setup)** to set up your environment, get your Okto API key, and spin up a simple React app. Once you’re comfortable with the basics, feel free to explore more advanced features or check out our example apps. -If you have any questions or need assistance, don’t hesitate to reach out via our **[Contact Us](./react-sdk/troubleshooting-faq/contact-us)** page or email us at `devrel@coindcx.com`. +If you have any questions or need assistance, don’t hesitate to reach out via our **[Troubleshooting](./react-sdk/troubleshooting)** page or email us at `devrel@coindcx.com`. **Happy Building!** diff --git a/content/docs/react-sdk/technical-reference.mdx b/content/docs/react-sdk/technical-reference.mdx index 258f958..2a9b7f8 100644 --- a/content/docs/react-sdk/technical-reference.mdx +++ b/content/docs/react-sdk/technical-reference.mdx @@ -105,7 +105,10 @@ import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; |--------------|----------| | APTOS | aptos:1 | | APTOS_TESTNET | aptos:2 | +| ARBITRUM | eip155:42161 | +| AVALANCHE | eip155:43114 | | BASE | eip155:8453 | +| BSC | eip155:56 | | POLYGON | eip155:137 | | POLYGON_TESTNET_AMOY | eip155:80002 | | SOLANA | solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp | @@ -130,10 +133,9 @@ import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; | Value | Description | |-------|-------------| - | `MINT` | Indicates that the order is for minting a new NFT. | | `NFT_TRANSFER` | Indicates that the order is for transferring an NFT to another address. | - | `TOKEN_TRANSFER_EXECUTE` | Indicates that the order is for executing a token transfer transaction. | - | `EXECUTE_RAW_TX` | Indicates that the order is for executing a raw blockchain transaction. | + | `TOKEN_TRANSFER` | Indicates that the order is for executing a token transfer transaction. | + | `RAW_TRANSACTION` | Indicates that the order is for executing a raw blockchain transaction. |
@@ -156,18 +158,33 @@ import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; +
### ENTITY_TYPE -

Defines the type of NFT or asset involved in the transaction.

+

Defines the category of asset involved in the transaction.

+
+
+ | Value | Description | + |-------|-------------| + | `TOKENS` | Fungible tokens | + | `NETWORKS` | Blockchain networks | + | `NFTS` | Non-fungible tokens | +
+
+ +--- +
+### ERC_TYPE +

Specifies the ERC standard for NFTs on EVM-compatible blockchains.

+
| Value | Description | |-------|-------------| - | `ERC721` | An ERC-721 standard NFT on EVM-compatible blockchains. | + | `ERC721` | An ERC-721 standard NFT on EVM-compatible blockchains | | `ERC1155` | An ERC-1155 standard NFT on EVM-compatible blockchains. | - | `NFT` | An NFT on non-EVM blockchains. |
@@ -181,7 +198,7 @@ import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';

Contains user authentication and session information.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `userId` | Unique identifier for the user | string | | `userAddress` | User's wallet address | string | @@ -203,7 +220,7 @@ const user = {

Represents a user operation for account abstraction.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `callData` | Execution call data | Hex | | `callGasLimit` | Gas limit for main call | Hex | @@ -246,7 +263,7 @@ const userOp = {

Represents a blockchain wallet with its network details.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `caipId` | Chain agnostic identifier | string | | `networkName` | Name of the network | string | @@ -268,7 +285,7 @@ const wallet = {

Describes a cryptocurrency token and its properties.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `address` | Token contract address | string | | `caipId` | Chain agnostic identifier | string | @@ -304,7 +321,7 @@ const token = {

Contains information about supported blockchain networks.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `caipId` | Chain agnostic identifier | string | | `networkName` | Network name | string | @@ -332,7 +349,7 @@ const network = {

Represents an order/transaction status and details.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `downstreamTransactionHash` | Array of downstream tx hashes | string[] | | `transactionHash` | Array of transaction hashes | string[] | @@ -361,7 +378,7 @@ const order = {

Parameters for initiating a token transfer.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `amount` | Transfer amount | number \| bigint | | `recipient` | Recipient's address | Address | @@ -382,7 +399,7 @@ const tokenTransferParams = {

Parameters for initiating an NFT transfer.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `caip2Id` | Chain identifier | string | | `collectionAddress` | NFT collection address | Address | @@ -407,7 +424,7 @@ const nftTransferParams = {

Contains user's portfolio and holdings information.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `aggregatedData` | Portfolio summary | Object | | `aggregatedData.holdingsCount` | Number of holdings | string | diff --git a/content/docs/typescript-sdk/authentication/google-oauth/auth-user-via-code.mdx b/content/docs/typescript-sdk/authentication/google-oauth/auth-user-via-code.mdx deleted file mode 100644 index 436a2c3..0000000 --- a/content/docs/typescript-sdk/authentication/google-oauth/auth-user-via-code.mdx +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Authenticate User using Google OAuth -description: Learn how to authenticate users with OAuth using the Okto SDK. -full: false ---- diff --git a/content/docs/typescript-sdk/authentication/google-oauth/meta.json b/content/docs/typescript-sdk/authentication/google-oauth/meta.json index 4ba12f8..c1ba8c5 100644 --- a/content/docs/typescript-sdk/authentication/google-oauth/meta.json +++ b/content/docs/typescript-sdk/authentication/google-oauth/meta.json @@ -3,7 +3,6 @@ "pages": [ "learn", "get-token-id", - "google-console-setup", - "auth-user-via-code" + "google-console-setup" ] } \ No newline at end of file diff --git a/content/docs/typescript-sdk/authentication/session-management/getAuthToken.mdx b/content/docs/typescript-sdk/authentication/session-management/getAuthToken.mdx new file mode 100644 index 0000000..fbe9722 --- /dev/null +++ b/content/docs/typescript-sdk/authentication/session-management/getAuthToken.mdx @@ -0,0 +1,78 @@ +--- +title: Get Auth Token +description: Learn how to retrieve the authorization token using the Okto SDK. +full: false +--- + +import { TypeTable } from 'fumadocs-ui/components/type-table'; +import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; +import { Callout } from 'fumadocs-ui/components/callout'; +import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; +import { Icon as IIcon } from '@iconify/react'; + +The `getAuthorizationToken()` method retrieves the current user's authorization token for authenticated operations. + +### Method Overview + +| Methods | Description | +|---------|-------------| +| async `OktoClient.getAuthorizationToken` | Get the current authorization token | + +
+ +## Get Authorization Token + +async `OktoClient.getAuthorizationToken()` retrieves the current authorization token for the authenticated user. + +### Parameters + +This method doesn't take any parameters. + +### Response + + + +| Field Name | Type | Description | +|------------|------|-------------| +| `result` | `Promise` | Returns the authorization token | + + + + + + + + ```typescript + import { OktoClient } from "@okto_web3/core-js-sdk"; + import { Env } from "@okto_web3/core-js-sdk/dist/core/types"; + + function TokenRetrieval() { + // Initialize OktoClient + const oktoClient = new OktoClient({ + environment: process.env.ENVIRONMENT as Env, + vendorPrivKey: process.env.VENDOR_PRIVATE_KEY as Env, + vendorSWA: process.env.VENDOR_SWA as Env, + }); + + async function getToken() { + try { + const token = await oktoClient.getAuthorizationToken(); + console.log("Auth token retrieved"); + } catch (error) { + console.error("Failed to get token:", error); + } + } + + return ; + } + ``` + + + + + +
+ + +The authorization token is a JWT that can be used to authenticate requests to Okto services. This token is automatically managed by the SDK for internal operations. + \ No newline at end of file diff --git a/content/docs/typescript-sdk/authentication/session-management/login.mdx b/content/docs/typescript-sdk/authentication/session-management/login.mdx deleted file mode 100644 index 46bbf48..0000000 --- a/content/docs/typescript-sdk/authentication/session-management/login.mdx +++ /dev/null @@ -1,130 +0,0 @@ ---- -title: Login -description: Learn how to login your users using Okto. -full: false ---- - -import { TypeTable } from 'fumadocs-ui/components/type-table'; -import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; -import { Callout } from 'fumadocs-ui/components/callout'; -import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; -import { Icon as IIcon } from '@iconify/react'; - -import '../../../styles.css'; - -### Method Overview - -| Methods | Description | -|---------------------------------------------------------------------------------|--------------------------------------| -| async [`loginUsingOauth`](#login-using-oauth) | Login using OAuth | -| async [`verifyLogin`](#verify-login) | Verify login | -| async [`generateAuthorizationToken`](#generate-authorization-token) | Generate authorization token | - -
- -## Login using OAuth - -async `loginUsingOauth(authData)` logins the user using OAuth. - -### Parameters - -| Parameter | Type | Description | -|-------------|-----------------------------|----------------------------------------| -| `data` | [`AuthData`](/api-docs#model/authdata) | Query being provided fetching the data | - -### Response - - - -| Field Name | Type | Description | -|------------|-----------------------|-----------------------------------------------| -| `result` | [`Promise`](/api-docs#model/user) | Returns the newly created user object | - - - - - - - - - ```typescript - const user = await oktoClient.loginUsingOAuth({ - idToken: 'idToken', // your ID token - provider: 'google', // your OAuth provider - }); - ``` - - - - - -
- -
- -## Verify login - -async `verifyLogin()` verifies the login of the user. - -### Parameters - -There are no parameters for this method. -### Response - - - -| Field Name | Type | Description | -|------------|-----------------------|-----------------------------------------------| -| `result` | [`Promise`](/api-docs#model/user) | Returns true if the login is verified | - - - - - - - - - ```typescript - const isVerified = await oktoClient.auth.verifyLogin(); - ``` - - - - - -
- -
- -## Generate authorization token - -`generateAuthorizationToken()` generates an authorization token for the user. - -### Parameters - -There are no parameters for this method. - -### Response - - - -| Field Name | Type | Description | -|------------|-----------------------|-----------------------------------------------| -| `result` | [`string`](/api-docs#model/user) | Returns the authorization token | - - - - - - - - - ```typescript - const token = await oktoClient.auth.generateAuthorizationToken(); - ``` - - - - - -
\ No newline at end of file diff --git a/content/docs/typescript-sdk/authentication/session-management/loginUsingOAuth.mdx b/content/docs/typescript-sdk/authentication/session-management/loginUsingOAuth.mdx new file mode 100644 index 0000000..9de9895 --- /dev/null +++ b/content/docs/typescript-sdk/authentication/session-management/loginUsingOAuth.mdx @@ -0,0 +1,110 @@ +--- +title: Login Using OAuth +description: Learn how to authenticate users using OAuth with the Okto SDK. +full: false +--- + +import { TypeTable } from 'fumadocs-ui/components/type-table'; +import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; +import { Callout } from 'fumadocs-ui/components/callout'; +import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; +import { Icon as IIcon } from '@iconify/react'; + +import '../../../styles.css'; + +The `loginUsingOAuth()` method authenticates users using OAuth providers. It generates a session key pair, creates an authenticate payload, and sends it to the Gateway service. Upon successful authentication, it updates the user session. + +### Method Overview + +| Method | Description | +|---------|-------------| +| async `OktoClient.loginUsingOAuth` | Authenticate user using OAuth | + +
+ +## Login Using OAuth + +async `OktoClient.loginUsingOAuth(data: AuthData)` authenticates users using OAuth providers and establishes their session. + +### Parameters + +| Parameter | Type | Description | +|-----------|------|-------------| +| `data` | `AuthData` | Authentication data containing the OAuth provider details | + +Where `AuthData` is one of: + +| Type | Fields | Description | +|------|--------|-------------| +| Google OAuth | `{ idToken: string; provider: 'google' }` | For authentication using Google OAuth | +| Okto Auth | `{ authToken: string; provider: 'okto' }` | For authentication using Okto token | + +### Response + + + +| Field Name | Type | Description | +|------------|------|-------------| +| `result` | `Promise` | Returns the user data on successful login | + + + + + + + +```typescript +import { OktoClient } from "@okto_web3/core-js-sdk"; +import { GoogleLogin } from '@react-oauth/google'; +import { Env } from "@okto_web3/core-js-sdk/dist/core/types"; + +function LoginComponent() { + // Initialize OktoClient + const oktoClient = new OktoClient({ + environment: process.env.ENVIRONMENT as Env, + vendorPrivKey: process.env.VENDOR_PRIVATE_KEY as Env, + vendorSWA: process.env.VENDOR_SWA as Env, + }); + + // Using Google OAuth + async function handleGoogleLogin(credentialResponse: any) { + try { + const user = await oktoClient.loginUsingOAuth({ + idToken: credentialResponse.credential, + provider: "google", + }); + console.log("Login successful:", user); + } catch (error) { + console.error("Login failed:", error); + } + } + + // Using Okto auth token + async function handleOktoLogin(authToken: string) { + try { + const user = await oktoClient.loginUsingOAuth({ + authToken: authToken, + provider: "okto", + }); + console.log("Login successful:", user); + } catch (error) { + console.error("Login failed:", error); + } + } + + return ( +
+ + +
+ ); +} +``` +
+
+
+
+ +
\ No newline at end of file diff --git a/content/docs/typescript-sdk/authentication/session-management/meta.json b/content/docs/typescript-sdk/authentication/session-management/meta.json index 412014d..55bb68d 100644 --- a/content/docs/typescript-sdk/authentication/session-management/meta.json +++ b/content/docs/typescript-sdk/authentication/session-management/meta.json @@ -1,6 +1,8 @@ { "title": "Session Management", "pages": [ - "login" + "loginUsingOAuth", + "verifyLogin", + "getAuthToken" ] } \ No newline at end of file diff --git a/content/docs/typescript-sdk/authentication/session-management/verifyLogin.mdx b/content/docs/typescript-sdk/authentication/session-management/verifyLogin.mdx new file mode 100644 index 0000000..b4888f9 --- /dev/null +++ b/content/docs/typescript-sdk/authentication/session-management/verifyLogin.mdx @@ -0,0 +1,74 @@ +--- +title: Verify Login +description: Learn how to verify user login status using the Okto SDK. +full: false +--- + +import { TypeTable } from 'fumadocs-ui/components/type-table'; +import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; +import { Callout } from 'fumadocs-ui/components/callout'; +import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; +import { Icon as IIcon } from '@iconify/react'; + +The `verifyLogin()` method checks if a user is currently logged in. If the user is not logged in, it automatically clears the auth options to maintain consistency. + +### Method Overview + +| Methods | Description | +|---------|-------------| +| async `OktoClient.verifyLogin` | Verify if user is logged in | + +
+ +## Verify Login + +async `OktoClient.verifyLogin()` checks the current login status of the user. + +### Parameters + +This method doesn't take any parameters. + +### Response + + + +| Field Name | Type | Description | +|------------|------|-------------| +| `result` | `Promise` | Returns true if user is logged in, false otherwise | + + + + + + + + ```typescript + import { OktoClient } from "@okto_web3/core-js-sdk"; + import { Env } from "@okto_web3/core-js-sdk/dist/core/types"; + + function AuthCheck() { + // Initialize OktoClient + const oktoClient = new OktoClient({ + environment: process.env.ENVIRONMENT as Env, + vendorPrivKey: process.env.VENDOR_PRIVATE_KEY as Env, + vendorSWA: process.env.VENDOR_SWA as Env, + }); + + async function checkLoginStatus() { + try { + const isLoggedIn = await oktoClient.verifyLogin(); + console.log("Login status:", isLoggedIn); + } catch (error) { + console.error("Verification failed:", error); + } + } + + return ; + } + ``` + + + + + +
diff --git a/content/docs/typescript-sdk/index.mdx b/content/docs/typescript-sdk/index.mdx index 9e7859e..67ffd3e 100644 --- a/content/docs/typescript-sdk/index.mdx +++ b/content/docs/typescript-sdk/index.mdx @@ -2,4 +2,82 @@ title: Overview of Typescript SDK description: Okto is a platform that allows you to integrate web3 functionality into your app without building things from scratch. full: false ---- \ No newline at end of file +--- + +import TechnologyCard from 'app/components/mdx/TechnologyCard'; +import { IoCodeSlashOutline } from "react-icons/io5"; + +## Introduction to Okto TypeScript SDK + +**Okto TypeScript SDK** is your comprehensive toolkit for integrating Web3 functionality into TypeScript applications. With an intuitive API and built-in type safety, it simplifies blockchain interactions—helping you quickly onboard users to the decentralized ecosystem and manage secure transactions with ease. + + +The Okto TypeScript SDK is built exclusively for client-side (frontend) usage. Do not use this SDK in server-side applications or backend services. + + +
+ } + title="GitHub Repository" + subtitle="View SDK Source Code" + link="https://github.com/okto-hq/okto-js-sdk-monorepo" + /> + } + title="Template Repository" + subtitle="Example Implementation" + link="https://github.com/okto-hq/okto-sdkv2-ts-template" + /> +
+ +--- + +## Installation & Quickstart + +Kickstart your project by following our [Quickstart Guide](/docs/typescript-sdk/quickstart). This guide will take you through installing the SDK, configuring your project, and executing your first transaction. + +--- + +## Key Features + +- **Wallet Management:** Create and manage embedded wallets for your users, ensuring secure and seamless account handling. +- **Multi-Chain Support:** Effortlessly interact with multiple blockchain networks, including EVM-compatible chains and beyond. +- **Asset Management:** Handle various digital assets like tokens and NFTs with robust functionalities. +- **Type Safety:** Leverage TypeScript’s powerful type system for enhanced code reliability and developer productivity. +- **Easy Integration:** Enjoy a simple setup process with minimal configuration required to get started. + +--- + +## Navigating the TypeScript SDK Docs + +Our documentation is organized to support every aspect of your development journey—from initial setup to advanced operations: + +### 1. Getting Started +- [Quickstart Guide](/docs/typescript-sdk/quickstart): Set up your TypeScript project and integrate the Okto SDK in minutes. +- [Prerequisites](/docs/typescript-sdk/prerequisites): A checklist of required dependencies, API keys, and setup steps. + +### 2. Authentication +Implement secure user login and session management: +- [Google OAuth](/docs/typescript-sdk/authentication/google-oauth/learn): Set up and authenticate users via Google. +- [Session Management](/docs/typescript-sdk/authentication/session-management/login): Manage user sessions and tokens. + +### 3. Usage & Features +Explore the full suite of capabilities provided by the SDK: +- [Usage Overview](/docs/typescript-sdk/usage/overview): Comprehensive guide to utilizing the SDK effectively. + +### 4. Additional Resources +Access further support and development tools: +- [Technical Reference](/docs/typescript-sdk/technical-reference): In-depth documentation of classes, methods, and data models. +- [SDK Error Warnings](/docs/typescript-sdk/sdk-error-warnings): A list of common error messages and troubleshooting tips. +- [Troubleshooting](/docs/typescript-sdk/troubleshooting): Guidance on resolving common issues. +- [Changelog](/docs/typescript-sdk/changelog): Detailed release notes and updates. +- [Feature Support](/docs/typescript-sdk/feature-support): Information on supported chains, tokens, and additional functionalities. +- [Example Apps](/docs/typescript-sdk/example-apps/template-repo): Sample projects showcasing best practices with the SDK. + +--- + +## Get Started + +Ready to dive in? Begin with our **[Quickstart Guide](/docs/typescript-sdk/quickstart)** to set up your environment, obtain your Okto API key, and build your first TypeScript application powered by the Okto SDK. +**Happy Building!** + diff --git a/content/docs/typescript-sdk/technical-reference.mdx b/content/docs/typescript-sdk/technical-reference.mdx index 258f958..2a9b7f8 100644 --- a/content/docs/typescript-sdk/technical-reference.mdx +++ b/content/docs/typescript-sdk/technical-reference.mdx @@ -105,7 +105,10 @@ import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; |--------------|----------| | APTOS | aptos:1 | | APTOS_TESTNET | aptos:2 | +| ARBITRUM | eip155:42161 | +| AVALANCHE | eip155:43114 | | BASE | eip155:8453 | +| BSC | eip155:56 | | POLYGON | eip155:137 | | POLYGON_TESTNET_AMOY | eip155:80002 | | SOLANA | solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp | @@ -130,10 +133,9 @@ import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; | Value | Description | |-------|-------------| - | `MINT` | Indicates that the order is for minting a new NFT. | | `NFT_TRANSFER` | Indicates that the order is for transferring an NFT to another address. | - | `TOKEN_TRANSFER_EXECUTE` | Indicates that the order is for executing a token transfer transaction. | - | `EXECUTE_RAW_TX` | Indicates that the order is for executing a raw blockchain transaction. | + | `TOKEN_TRANSFER` | Indicates that the order is for executing a token transfer transaction. | + | `RAW_TRANSACTION` | Indicates that the order is for executing a raw blockchain transaction. | @@ -156,18 +158,33 @@ import { Accordion, Accordions } from 'fumadocs-ui/components/accordion'; +
### ENTITY_TYPE -

Defines the type of NFT or asset involved in the transaction.

+

Defines the category of asset involved in the transaction.

+
+
+ | Value | Description | + |-------|-------------| + | `TOKENS` | Fungible tokens | + | `NETWORKS` | Blockchain networks | + | `NFTS` | Non-fungible tokens | +
+
+ +--- +
+### ERC_TYPE +

Specifies the ERC standard for NFTs on EVM-compatible blockchains.

+
| Value | Description | |-------|-------------| - | `ERC721` | An ERC-721 standard NFT on EVM-compatible blockchains. | + | `ERC721` | An ERC-721 standard NFT on EVM-compatible blockchains | | `ERC1155` | An ERC-1155 standard NFT on EVM-compatible blockchains. | - | `NFT` | An NFT on non-EVM blockchains. |
@@ -181,7 +198,7 @@ import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';

Contains user authentication and session information.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `userId` | Unique identifier for the user | string | | `userAddress` | User's wallet address | string | @@ -203,7 +220,7 @@ const user = {

Represents a user operation for account abstraction.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `callData` | Execution call data | Hex | | `callGasLimit` | Gas limit for main call | Hex | @@ -246,7 +263,7 @@ const userOp = {

Represents a blockchain wallet with its network details.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `caipId` | Chain agnostic identifier | string | | `networkName` | Name of the network | string | @@ -268,7 +285,7 @@ const wallet = {

Describes a cryptocurrency token and its properties.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `address` | Token contract address | string | | `caipId` | Chain agnostic identifier | string | @@ -304,7 +321,7 @@ const token = {

Contains information about supported blockchain networks.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `caipId` | Chain agnostic identifier | string | | `networkName` | Network name | string | @@ -332,7 +349,7 @@ const network = {

Represents an order/transaction status and details.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `downstreamTransactionHash` | Array of downstream tx hashes | string[] | | `transactionHash` | Array of transaction hashes | string[] | @@ -361,7 +378,7 @@ const order = {

Parameters for initiating a token transfer.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `amount` | Transfer amount | number \| bigint | | `recipient` | Recipient's address | Address | @@ -382,7 +399,7 @@ const tokenTransferParams = {

Parameters for initiating an NFT transfer.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `caip2Id` | Chain identifier | string | | `collectionAddress` | NFT collection address | Address | @@ -407,7 +424,7 @@ const nftTransferParams = {

Contains user's portfolio and holdings information.

-| Key | Value | Data Type | +| Key | Description | Data Type | |-----|--------|-----------| | `aggregatedData` | Portfolio summary | Object | | `aggregatedData.holdingsCount` | Number of holdings | string | diff --git a/content/docs/typescript-sdk/usage/OktoClient.mdx b/content/docs/typescript-sdk/usage/OktoClient.mdx index c8d4b43..1dbf1a5 100644 --- a/content/docs/typescript-sdk/usage/OktoClient.mdx +++ b/content/docs/typescript-sdk/usage/OktoClient.mdx @@ -18,9 +18,9 @@ import '../../styles.css'; | Parameter | Type | Description | |-------------|-----------------------------|----------------------------------------| -| `environment` | [`string`](/api-docs#model/userop) | The environment to use | -| `vendorPriKey` | [`string`](/api-docs#model/userop) | The vendor private key to use | -| `vendorSWA` | [`string`](/api-docs#model/userop) | The vendor's sender wallet address to use | +| `environment` | [`string`](/docs/typescript-sdk/technical-reference#models) | The environment to use | +| `vendorPriKey` | [`string`](/docs/typescript-sdk/technical-reference#models) | The vendor private key to use | +| `vendorSWA` | [`string`](/docs/typescript-sdk/technical-reference#models) | The vendor's sender wallet address to use | ### Response diff --git a/content/docs/typescript-sdk/usage/estimate.mdx b/content/docs/typescript-sdk/usage/estimate.mdx index 0ba4d59..b64cdc6 100644 --- a/content/docs/typescript-sdk/usage/estimate.mdx +++ b/content/docs/typescript-sdk/usage/estimate.mdx @@ -22,7 +22,7 @@ import '../../styles.css'; ## Estimate -async `estimate(OktoClient, recipientWalletAddress, networkId, tokenAddress, amount)` estimates a user operation. +async `estimate(OktoClient, recipientWalletAddress, networkId, tokenAddress, amount)` estimates a user operation. ### Parameters diff --git a/content/docs/typescript-sdk/usage/executeUserOp.mdx b/content/docs/typescript-sdk/usage/executeUserOp.mdx index 305f666..356fa06 100644 --- a/content/docs/typescript-sdk/usage/executeUserOp.mdx +++ b/content/docs/typescript-sdk/usage/executeUserOp.mdx @@ -22,7 +22,7 @@ import '../../styles.css'; ## Execute UserOp -async `executeUserOp(userOp)` executes a user operation. +async `executeUserOp(userOp)` executes a user operation. ### Parameters @@ -36,7 +36,7 @@ import '../../styles.css'; | Field Name | Type | Description | |------------|-----------------------|-----------------------------------------------| -| `result` | [`string`](/api-docs#model/userop) | Returns the result of the user operation | +| `result` | [`string`](/docs/typescript-sdk/technical-reference#models) | Returns the result of the user operation | diff --git a/content/docs/typescript-sdk/usage/getAccount.mdx b/content/docs/typescript-sdk/usage/getAccount.mdx index 9e7c351..eea77ef 100644 --- a/content/docs/typescript-sdk/usage/getAccount.mdx +++ b/content/docs/typescript-sdk/usage/getAccount.mdx @@ -12,6 +12,8 @@ import { Icon as IIcon } from '@iconify/react'; import '../../styles.css'; +Okto SDK provides the `getAccount()` method to retrieve details of wallets connected to the current user's Okto account. This includes both embedded wallets created via Okto and external wallets connected by the user (e.g., MetaMask, Phantom). + ### Method Overview | Methods | Description | @@ -22,7 +24,9 @@ import '../../styles.css'; ## Get Account -async `getAccount(OktoClient)` returns the list of wallets of the user. +async `getAccount()` retrieves the list of all wallets associated with the currently authenticated user. + +In Okto, an **account** represents the user's identity in the Okto ecosystem, encompassing both embedded wallets seamlessly created by Okto and external wallets users choose to connect. ### Parameters @@ -40,19 +44,37 @@ import '../../styles.css'; +### Example - + ```typescript import { getAccount } from "@okto_web3/core-js-sdk/userop"; - const wallets = await getAccount(); + const wallets = await getAccount(oktoClient); ``` + + +```json +{ + "status": "success", + "data": [ + { + "caip_id": "eip155:10", + "network_name": "OPTIMISM", + "address": "0x6698c56f99EaF4662cD70f974Cf787926e47781b", + "network_id": "f0620691-ce05-3d5c-94c7-1f2cf275c781", + "network_symbol": "OP" + } + ] +} +``` + diff --git a/content/docs/typescript-sdk/usage/getChains.mdx b/content/docs/typescript-sdk/usage/getChains.mdx index ce219d6..06fb545 100644 --- a/content/docs/typescript-sdk/usage/getChains.mdx +++ b/content/docs/typescript-sdk/usage/getChains.mdx @@ -1,6 +1,6 @@ --- title: Get Chains -description: Get the chains of a user. +description: Learn how to retrieve supported blockchain networks using the Okto SDK. full: false --- @@ -12,6 +12,8 @@ import { Icon as IIcon } from '@iconify/react'; import '../../styles.css'; +The `getChains` function retrieves a list of all blockchain networks supported by Okto. This includes information about each chain's configuration, network details, and supported features. + ### Method Overview | Methods | Description | @@ -22,7 +24,7 @@ import '../../styles.css'; ## Get Chains -async `getChains(OktoClient)` returns the list of supported chains. +async `getChains(OktoClient)` returns the list of supported chains. ### Parameters @@ -40,19 +42,80 @@ import '../../styles.css'; +### Example - + ```typescript import { getChains } from "@okto_web3/core-js-sdk/explorer"; - const chains = await getChains(); + const chains = await getChains(oktoClient); ``` + + +```json +{ + "status": "success", + "data": { + "network": [ + { + "caip_id": "eip155:56", + "network_name": "BSC", + "chain_id": "56", + "logo": "BSC", + "sponsorship_enabled": true, + "gsn_enabled": false, + "type": "EVM", + "network_id": "9a26afcf-ed62-43d8-91ea-42dc7cd55890", + "onramp_enabled": false, + "whitelisted": true + }, + { + "caip_id": "eip155:42161", + "network_name": "ARBITRUM", + "chain_id": "42161", + "logo": "ARB", + "sponsorship_enabled": false, + "gsn_enabled": false, + "type": "EVM", + "network_id": "a003a74c-4dd2-3fc7-8c70-c080c9ca5afb", + "onramp_enabled": false, + "whitelisted": true + }, + { + "caip_id": "eip155:137", + "network_name": "POLYGON", + "chain_id": "137", + "logo": "POLYGON", + "sponsorship_enabled": true, + "gsn_enabled": false, + "type": "EVM", + "network_id": "ae506585-0ba7-32f3-8b92-120ddf940198", + "onramp_enabled": false, + "whitelisted": true + }, + { + "caip_id": "eip155:43114", + "network_name": "AVALANCHE", + "chain_id": "43114", + "logo": "AVAX", + "sponsorship_enabled": true, + "gsn_enabled": false, + "type": "EVM", + "network_id": "a3b96c4e-dc81-3c52-a9ee-729974ea74a0", + "onramp_enabled": false, + "whitelisted": true + } + ] + } +} +``` + diff --git a/content/docs/typescript-sdk/usage/getNftCollections.mdx b/content/docs/typescript-sdk/usage/getNftCollections.mdx index bb8137c..4c5a0a3 100644 --- a/content/docs/typescript-sdk/usage/getNftCollections.mdx +++ b/content/docs/typescript-sdk/usage/getNftCollections.mdx @@ -22,7 +22,7 @@ import '../../styles.css'; ## Get NFT Collections -async `getNftCollections(OktoClient)` returns the list of NFT collections of the user. +async `getNftCollections(OktoClient)` returns the list of NFT collections of the user. ### Parameters diff --git a/content/docs/typescript-sdk/usage/getOrdersHistory.mdx b/content/docs/typescript-sdk/usage/getOrdersHistory.mdx index bf54d73..00f8645 100644 --- a/content/docs/typescript-sdk/usage/getOrdersHistory.mdx +++ b/content/docs/typescript-sdk/usage/getOrdersHistory.mdx @@ -12,6 +12,8 @@ import { Icon as IIcon } from '@iconify/react'; import '../../styles.css'; +The `getOrdersHistory` function retrieves the list of orders for the authenticated user. + ### Method Overview | Methods | Description | @@ -22,7 +24,7 @@ import '../../styles.css'; ## Get Orders History -async `getOrdersHistory(OktoClient)` returns the list of orders history of the user. +async `getOrdersHistory(OktoClient)` retrieves the user's order history. ### Parameters @@ -40,19 +42,55 @@ import '../../styles.css'; +### Example - + ```typescript import { getOrdersHistory } from "@okto_web3/core-js-sdk/explorer"; - const ordersHistory = await getOrdersHistory(); + const ordersHistory = await getOrdersHistory(oktoClient); ``` + + +```json +{ + "status": "success", + "data": { + "count": 1, + "items": [ + { + "downstream_transaction_hash": [ + "0xb30aacea6ee3883939255195172a62110b02aeb03dc590e0cd4d878995bc958b" + ], + "transaction_hash": [ + "0x1378f79faffa6ff1242c5d4ebdbc8fffc4bdbc44723cb63041d54fc67c671f97", + "0xd6f8416207f1589a600ce1c1a1b492b28f0ab5e9bcb499eb0886f886d4daed75" + ], + "status": "SUCCESSFUL", + "intent_id": "21260b29-2e72-4337-b494-c69d62dd3c92", + "intent_type": "TOKEN_TRANSFER", + "network_name": "OKTO_DEVNET", + "caip_id": "eip155:24879", + "details": { + "amount": "164060000", + "networkId": "eip155:137", + "recipientWalletAddress": "0x08a51013e6db8CE4594e0F9c0D13c96772d24336", + "tokenAddress": "" + }, + "reason": "", + "block_timestamp": 1738761051000 + } + ] + } +} +``` + diff --git a/content/docs/typescript-sdk/usage/getPortfolio.mdx b/content/docs/typescript-sdk/usage/getPortfolio.mdx index 5b68df2..0ba0c69 100644 --- a/content/docs/typescript-sdk/usage/getPortfolio.mdx +++ b/content/docs/typescript-sdk/usage/getPortfolio.mdx @@ -12,6 +12,8 @@ import { Icon as IIcon } from '@iconify/react'; import '../../styles.css'; +The `getPortfolio` function retrieves the aggregated portfolio for the authenticated user. + ### Method Overview | Methods | Description | @@ -22,7 +24,8 @@ import '../../styles.css'; ## Get Portfolio -async `getPortfolio(OktoClient)` returns the portfolio of the user. +async `getPortfolio(OktoClient)` retrieves the user's aggregated portfolio data. + ### Parameters | Parameter | Type | Description | @@ -39,19 +42,73 @@ import '../../styles.css'; +### Example - + ```typescript import { getPortfolio } from "@okto_web3/core-js-sdk/explorer"; - const portfolio = await getPortfolio(); + const portfolio = await getPortfolio(oktoClient); ``` + + +```json +{ + "status": "success", + "data": { + "aggregated_data": { + "holdings_count": "6", + "holdings_price_inr": "594.5431000000001", + "holdings_price_usdt": "8.821019999999999", + "total_holding_price_inr": "594.5431000000001", + "total_holding_price_usdt": "8.821019999999999" + }, + "group_tokens": [ + { + "id": "a9e192bb-bd18-3a47-ab07-5ecff29776e3", + "name": "Polygon Ecosystem Token", + "symbol": "POL", + "short_name": "POL", + "token_image": "https://www.dextools.io/resources/tokens/logos/3/ether/0x455e53cbb86018ac2b8092fdcd39d8444affc3f6.png?1698233684", + "token_address": "", + "group_id": "c885bfd2-abff-30d5-a0ba-aed6573a836d", + "network_id": "ae506585-0ba7-32f3-8b92-120ddf940198", + "precision": "4", + "network_name": "POLYGON", + "is_primary": false, + "balance": "3.7258", + "holdings_price_usdt": "1.14661", + "holdings_price_inr": "77.28166", + "aggregation_type": "group", + "tokens": [ + { + "id": "a9e192bb-bd18-3a47-ab07-5ecff29776e3", + "name": "Polygon Ecosystem Token", + "symbol": "POL", + "short_name": "POL", + "token_image": "https://www.dextools.io/resources/tokens/logos/3/ether/0x455e53cbb86018ac2b8092fdcd39d8444affc3f6.png?1698233684", + "token_address": "", + "network_id": "ae506585-0ba7-32f3-8b92-120ddf940198", + "precision": "4", + "network_name": "POLYGON", + "is_primary": true, + "balance": "3.7258", + "holdings_price_usdt": "1.14661", + "holdings_price_inr": "77.28166" + } + ] + } + ] + } +} +``` + diff --git a/content/docs/typescript-sdk/usage/getPortfolioActivity.mdx b/content/docs/typescript-sdk/usage/getPortfolioActivity.mdx index 44d2c7d..eecc9a4 100644 --- a/content/docs/typescript-sdk/usage/getPortfolioActivity.mdx +++ b/content/docs/typescript-sdk/usage/getPortfolioActivity.mdx @@ -12,6 +12,8 @@ import { Icon as IIcon } from '@iconify/react'; import '../../styles.css'; +The `getPortfolioActivity` function retrieves the portfolio activity for the authenticated user. + ### Method Overview | Methods | Description | @@ -22,7 +24,8 @@ import '../../styles.css'; ## Get Portfolio Activity -async `getPortfolioActivity(OktoClient)` returns the portfolio activity of the user. +async `getPortfolioActivity(OktoClient)` retrieves the user's portfolio activity history. + ### Parameters | Parameter | Type | Description | @@ -39,19 +42,79 @@ import '../../styles.css'; +### Example - + ```typescript import { getPortfolioActivity } from "@okto_web3/core-js-sdk/explorer"; - const portfolioActivity = await getPortfolioActivity(); + const portfolioActivity = await getPortfolioActivity(oktoClient); ``` + + +```json +{ + "status": "success", + "data": { + "count": 50, + "activity": [ + { + "symbol": "", + "image": "", + "name": "", + "short_name": "", + "id": "", + "group_id": "", + "description": "NFT Deposit", + "quantity": "1.000000000000000000", + "amount": "", + "order_type": "EXTERNAL_TRANSFER", + "transfer_type": "DEPOSIT", + "status": true, + "created_at": 1739176632, + "updated_at": 1739176632, + "timestamp": 1739176632, + "tx_hash": "0x4e20af759a50080e548cc40f2504e569935ce0f3255bed9c9121e3fdaebc36d1", + "network_id": "ae506585-0ba7-32f3-8b92-120ddf940198", + "network_name": "POLYGON", + "network_explorer_url": "https://polygonscan.com/", + "network_symbol": "POLYGON", + "caip_id": "eip155:137" + }, + { + "symbol": "", + "image": "", + "name": "", + "short_name": "", + "id": "", + "group_id": "", + "description": "NFT Deposit", + "quantity": "1.000000000000000000", + "amount": "", + "order_type": "EXTERNAL_TRANSFER", + "transfer_type": "DEPOSIT", + "status": true, + "created_at": 1739170093, + "updated_at": 1739170093, + "timestamp": 1739170093, + "tx_hash": "0xba4eec0a5b1b1c6e4f741a94eb6350bffab0a2a822041ca69ccaee1c7978f0c8", + "network_id": "ae506585-0ba7-32f3-8b92-120ddf940198", + "network_name": "POLYGON", + "network_explorer_url": "https://polygonscan.com/", + "network_symbol": "POLYGON", + "caip_id": "eip155:137" + } + ] + } +} +``` + diff --git a/content/docs/typescript-sdk/usage/getPortfolioNFT.mdx b/content/docs/typescript-sdk/usage/getPortfolioNFT.mdx index 8f8a4ab..9d35c53 100644 --- a/content/docs/typescript-sdk/usage/getPortfolioNFT.mdx +++ b/content/docs/typescript-sdk/usage/getPortfolioNFT.mdx @@ -12,6 +12,8 @@ import { Icon as IIcon } from '@iconify/react'; import '../../styles.css'; +The `getPortfolioNFT` function retrieves the list of NFTs in the authenticated user's portfolio. + ### Method Overview | Methods | Description | @@ -22,7 +24,8 @@ import '../../styles.css'; ## Get Portfolio NFT -async `getPortfolioNFT(OktoClient)` returns the NFT portfolio of the user. +async `getPortfolioNFT(OktoClient)` returns the NFT portfolio of the user. + ### Parameters | Parameter | Type | Description | @@ -39,19 +42,48 @@ import '../../styles.css'; +### Example - + ```typescript import { getPortfolioNFT } from "@okto_web3/core-js-sdk/explorer"; - const portfolioNFT = await getPortfolioNFT(); + const portfolioNFT = await getPortfolioNFT(oktoClient); ``` + + +```json +{ + "status": "success", + "data": { + "count": 2, + "details": [ + { + "caip_id": "eip155:8453", + "network_name": "BASE", + "entity_type": "ERC721", + "collection_address": "0x19fc518b9eed93f70aa4b49133d303101699467a", + "collection_name": "MAYANKONBOARDINGTEST", + "nft_id": "5", + "image": "ipfs://QmWypyEUGo9mpt5R2EXbAwVRvtaAfg8TTyzwZEdDRowdov", + "quantity": "1.000000000000000000", + "token_uri": "https://ipfs.io/ipfs/QmT434r64HQXdkpKo5fRCCn2PzxmQQPtXgGSnrUVzpPwaw", + "description": "Marks a splashy start to your journey of conquering the ocean of web3 and achieving the ultimate feat of becoming a whale, metaphorically atleast ;)", + "nft_name": "Dolphin NFT - CoinDCX Maxis", + "explorer_smart_contract_url": "https://basescan.org/search?f=0&q=0x19fc518b9eed93f70aa4b49133d303101699467a", + "collection_image": "https://coindcx.s3.amazonaws.com/static/images/474c04b3-3abd-4d45-8cf4-f59871e15aec/Unfold_23.png" + } + ] + } +} +``` + diff --git a/content/docs/typescript-sdk/usage/getTokens.mdx b/content/docs/typescript-sdk/usage/getTokens.mdx index 5e9a3cc..12c795e 100644 --- a/content/docs/typescript-sdk/usage/getTokens.mdx +++ b/content/docs/typescript-sdk/usage/getTokens.mdx @@ -1,6 +1,6 @@ --- title: Get Tokens -description: Okto is a platform that allows you to integrate web3 functionality into your app without building things from scratch. +description: Learn how to retrieve supported tokens using the Okto SDK. full: false --- @@ -12,6 +12,9 @@ import { Icon as IIcon } from '@iconify/react'; import '../../styles.css'; +The `getTokens` function fetches the list of supported tokens from the backend. + + ### Method Overview | Methods | Description | @@ -22,7 +25,7 @@ import '../../styles.css'; ## Get Tokens -async `getTokens(OktoClient)` returns the list of supported tokens. +async `getTokens(OktoClient)` returns the list of supported tokens. ### Parameters @@ -40,18 +43,78 @@ import '../../styles.css'; +### Example - + ```typescript import { getTokens } from "@okto_web3/core-js-sdk/explorer"; - const tokens = await getTokens(); + const tokens = await getTokens(oktoClient); ``` + + +```json +{ + "status": "success", + "data": [ + { + "caip_id": "eip155:10", + "network_name": "OPTIMISM", + "address": "0x6698c56f99EaF4662cD70f974Cf787926e47781b", + "network_id": "f0620691-ce05-3d5c-94c7-1f2cf275c781", + "network_symbol": "OP" + } + ] +} +``` + + +```json +{ + "status": "success", + "data": { + "count": 24, + "tokens": [ + { + "address": "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2", + "caip_id": "eip155:8453", + "symbol": "USDT", + "image": "https://images.okto.tech/token_logos/USDT.png", + "name": "", + "short_name": "Tether USD", + "id": "a060dd71-4ab2-3865-9530-5c4288f40506", + "group_id": "83e77d34-88e9-3e59-a678-231fbf336b08", + "is_primary": false, + "network_id": "9400de12-efc6-3e69-ab02-0eaf5aaf21e5", + "network_name": "BASE", + "onramp_enabled": false, + "whitelisted": true + }, + { + "address": "", + "caip_id": "eip155:56", + "symbol": "BNB", + "image": "https://images.okto.tech/token_logos/BNB.png", + "name": "BNB", + "short_name": "BNB", + "id": "d34383bb-b6b1-3d10-ad7f-60aef8d548fa", + "group_id": "9fc268f9-2a56-315a-bd6e-b6a91aceb79c", + "is_primary": true, + "network_id": "9a26afcf-ed62-43d8-91ea-42dc7cd55890", + "network_name": "BSC", + "onramp_enabled": false, + "whitelisted": true + } + ] + } +} +``` + diff --git a/content/docs/typescript-sdk/usage/login.mdx b/content/docs/typescript-sdk/usage/login.mdx deleted file mode 100644 index 3f19c42..0000000 --- a/content/docs/typescript-sdk/usage/login.mdx +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Login -description: Okto is a platform that allows you to integrate web3 functionality into your app without building things from scratch. -full: false ---- diff --git a/content/docs/typescript-sdk/usage/logout.mdx b/content/docs/typescript-sdk/usage/logout.mdx deleted file mode 100644 index a291e76..0000000 --- a/content/docs/typescript-sdk/usage/logout.mdx +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Logout -description: Okto is a platform that allows you to integrate web3 functionality into your app without building things from scratch. -full: false ---- diff --git a/content/docs/typescript-sdk/usage/nftCreateCollection.mdx b/content/docs/typescript-sdk/usage/nftCreateCollection.mdx index 83c2fac..b2b2afc 100644 --- a/content/docs/typescript-sdk/usage/nftCreateCollection.mdx +++ b/content/docs/typescript-sdk/usage/nftCreateCollection.mdx @@ -22,7 +22,7 @@ import '../../styles.css'; ## Create NFT Collection -async `nftCollectionCreation(OktoClient, data)` creates a new NFT collection. +async `nftCollectionCreation(OktoClient, data)` creates a new NFT collection. ### Parameters diff --git a/content/docs/typescript-sdk/usage/nftTransfer.mdx b/content/docs/typescript-sdk/usage/nftTransfer.mdx index e201cc6..3923b35 100644 --- a/content/docs/typescript-sdk/usage/nftTransfer.mdx +++ b/content/docs/typescript-sdk/usage/nftTransfer.mdx @@ -22,7 +22,7 @@ import '../../styles.css'; ## NFT Transfer -async `nftTransfer(OktoClient, data)` transfers an NFT. +async `nftTransfer(OktoClient, data)` transfers an NFT. ### Parameters diff --git a/content/docs/typescript-sdk/usage/signUserOp.mdx b/content/docs/typescript-sdk/usage/signUserOp.mdx index 47960f3..7e117f1 100644 --- a/content/docs/typescript-sdk/usage/signUserOp.mdx +++ b/content/docs/typescript-sdk/usage/signUserOp.mdx @@ -22,7 +22,7 @@ import '../../styles.css'; ## Sign UserOp -async `signUserOp(userOp)` signs a user operation. +async `signUserOp(userOp)` signs a user operation. ### Parameters diff --git a/content/docs/typescript-sdk/usage/tokenTransfer.mdx b/content/docs/typescript-sdk/usage/tokenTransfer.mdx index 9d2805f..792314d 100644 --- a/content/docs/typescript-sdk/usage/tokenTransfer.mdx +++ b/content/docs/typescript-sdk/usage/tokenTransfer.mdx @@ -22,7 +22,7 @@ import '../../styles.css'; ## Token Transfer -async `tokenTransfer(OktoClient, data)` transfers a token. +async `tokenTransfer(OktoClient, data)` transfers a token. ### Parameters diff --git a/public/images/erc4337-flow.png b/public/images/erc4337-flow.png new file mode 100644 index 0000000..44ad47b Binary files /dev/null and b/public/images/erc4337-flow.png differ diff --git a/public/images/react-template.png b/public/images/react-template.png new file mode 100644 index 0000000..5299504 Binary files /dev/null and b/public/images/react-template.png differ