Zebec Network 백서

Zebec Network

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 20쪽 중 7쪽

l for enterprises, available in the Enterprise Payroll application. **Zebec Payroll** lets enterprises pay employees and contractors globally in stablecoins — settling in seconds and, optionally, streaming pay by the second. {% hint style="info" %} **Available in:** 🏢 [Enterprise Payroll](/zebec-application-suite/enterprise-payroll) {% endhint %} ## What it does * Enterprises fund an on-chain treasury wallet with stablecoins. * Zebec disburses pay directly to employee and contractor wallets. * Recipients can withdraw pay as it accrues or load it onto a Zebec card. ## Documentation The full payroll guide lives in the Enterprise Payroll user guide: * [Enterprise Payroll overview](/zebec-application-suite/enterprise-payroll) * [Getting started](/zebec-application-suite/enterprise-payroll/getting-started) * [Running payroll](/zebec-application-suite/enterprise-payroll/running-payroll) * [Streaming payroll](/zebec-application-suite/enterprise-payroll/streaming-payroll) * [Cards for payees](/zebec-application-suite/enterprise-payroll/for-payees-and-contractors/cards-for-payees) ## Related products * [USX / Solstice yield](/zebec-product-information/yield/usx-solstice) * [MoneyGram off-ramp](/zebec-product-information/fiat-off-ramps/moneygram) # Overview Developer documentation for Zebec SDKs and APIs. This section is for engineers integrating Zebec into their own applications. ## What is available * **SDKs** — Zebec provides SDKs for card contract payments, streaming, staking, and other products across multiple chains. * **Partner API** — a B2B surface for partners topping up existing Carbon cards and handling end-user 2FA on behalf of their users. ## SDKs * [Partners Card SDK](/developer-docs/sdks/partner-card-sdk) — available for EVM and Solana; supports virtual card purchases and Carbon card top-ups. * [Streaming SDK](/developer-docs/sdks/streaming-sdk) — available for [Stellar](/developer-docs/sdks/streaming-sdk/stellar-streaming-sdk), [Solana](/developer-docs/sdks/streaming-sdk/solana-streaming-sdk), and [Aleo](/developer-docs/sdks/streaming-sdk/aleo-streaming-sdk). * [Staking SDK](/developer-docs/sdks/staking-sdk) — coming soon. ## Partner API * [Overview](/developer-docs/partner-api) * [Authentication](/developer-docs/partner-api/authentication) * [Cards](/developer-docs/partner-api/cards) * [Top-up flow](/developer-docs/partner-api/topup-flow) {% hint style="info" %} For the live Partner API schemas, see the Swagger UI at <https://dev-super.api.zebec.io/api/partner>. {% endhint %} # SDKs Zebec SDKs for card contract payments, streaming, staking, and more. Zebec offers a growing set of SDKs for different chains and product surfaces. ## Available SDKs | SDK | Status | Description | | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | | [Partners Card SDK](/developer-docs/sdks/partner-card-sdk) | Available for EVM and Solana | Quote and purchase virtual cards, including Carbon card top-ups. | | [Streaming SDK](/developer-docs/sdks/streaming-sdk) | Available for [Stellar](/developer-docs/sdks/streaming-sdk/stellar-streaming-sdk), [Solana](/developer-docs/sdks/streaming-sdk/solana-streaming-sdk), [Aleo](/developer-docs/sdks/streaming-sdk/aleo-streaming-sdk) | Program real-time payment streams on supported chains. | | [Staking SDK](/developer-docs/sdks/staking-sdk) | Coming Soon | Integrate $ZBCN staking and reward flows. | The Partners Card SDK, Stellar Streaming SDK, Solana Streaming SDK, and Aleo Streaming SDK include installation and configuration instructions. {% hint style="warning" %} The Staking SDK is not yet published. Its installation and API reference will be added once it is available. {% endhint %} ## Getting help If you need early access or have integration questions, contact <support@zebec.io> or your Zebec partner engineer. # Partners Card SDK Integrate Zebec virtual card purchases and Carbon card top-ups on EVM and Solana. The Zebec Partners Card SDK lets partners quote and purchase Zebec virtual cards. It supports Ethereum, BNB Smart Chain, Polygon, and Base through `ZebecCardEvmService`. Solana integrations use `ZebecCardSolanaService` with the companion `@zebec-network/zebec-card-v2-sdk`. The SDK handles wallet transactions and coordinates the purchase result with the Partner API. Keep authentication, end-user OTP, delegated access tokens, quote requests, preflight checks, and status polling in your Partner API client. See the [Partner API docs](/developer-docs/partner-api) for those operations. ## Installation ```bash npm install @zebec-network/partners-card-sdk ``` ```bash yarn add @zebec-network/partners-card-sdk ``` ## Authentication and security Zebec supplies partners with an API key and encryption key. The SDK keeps these constructor parameters for compatibility with integrations that use its legacy API client. {% hint style="warning" %} Do not commit either credential or expose them in browser-delivered source code. The SDK does not perform end-user login, OTP verification, OAuth, or an access-token exchange. {% endhint %} Partner API environments: | Environment | Base URL | | ----------- | -------------------------------- | | Production | `https://api.superapp.zebec.io` | | Sandbox | `https://dev-super.api.zebec.io` | For the current Partner v1 API, supply a `purchaseApiAdapter`. It connects your authenticated Partner API client to the SDK's on-chain purchase workflow without adding authentication state to the SDK. ```ts const service = new ZebecCardEvmService( signer, 56, { apiKey, encryptionKey }, { purchaseApiAdapter: { ping: () => partnerApi.healthCheck(), fetchZebecCardPrograms: (countryCode) => partnerApi.getCardPrograms(countryCode), purchaseCard: (orderRequest) => partnerApi.submitConfirmedPurchase(orderRequest), }, }, ); ``` The adapter methods in this example belong to your Partner API client. Existing integrations should omit `purchaseApiAdapter` only when their deployment still supports the SDK's legacy routes and authentication format. The current Super App hosts do not expose the legacy `/orders/*` routes. ## EVM integration ### Supported chains | Chain | Chain ID | SDK enum | | ----------------------- | ---------- | ------------------------------- | | Ethereum | `1` | `SupportedEvmChain.Mainnet` | | Sepolia | `11155111` | `SupportedEvmChain.Sepolia` | | Base | `8453` | `SupportedEvmChain.Base` | | BNB Smart Chain | `56` | `SupportedEvmChain.Bsc` | | BNB Smart Chain Testnet | `97` | `SupportedEvmChain.BscTestnet` | | Polygon | `137` | `SupportedEvmChain.Polygon` | | Polygon Amoy | `80002` | `SupportedEvmChain.PolygonAmoy` | Set `sandbox: true` when using a testnet. Production mode accepts only mainnet chains, and sandbox mode accepts only testnet chains. ### Create a service Create `ZebecCardEvmService` with an Ethers signer, a supported chain ID, and credentials supplied by Zebec. ```ts import { Recipient, ZebecCardEvmService, } from "@zebec-network/partners-card-sdk"; // Provide an ethers Signer from your secure signing integration. const service = new ZebecCardEvmService( signer, 56, { apiKey, encryptionKey }, { purchaseApiAdapter }, ); ``` For a testnet service: ```ts const service = new ZebecCardEvmService( signer, 97, { apiKey, encryptionKey }, { sandbox: true, purchaseApiAdapter }, ); ``` ### Create a recipient `Recipient.create()` validates the partner's participant ID and the cardholder's contact details. ```ts const recipient = Recipient.create( "customer123", // participantId: 1-20 alphanumeric characters "Sample", // firstName "Customer", // lastName "customer@example.com", // emailAddress "+15555550100", // mobilePhone "en-US", // language "San Francisco", // city "CA", // state "94105", // postalCode "USA", // ISO 3166-1 alpha-3 country code "123 Market Street", // address1 ); ``` `address2` is an optional final argument. Each address line can contain up to 50 characters, and the email address can contain up to 80 characters. ### Quote and purchase With the current Partner v1 API, request the quote and run preflight through your Partner API client. Then pass the quote unchanged to `purchaseCard()`. ```ts const programDetails = await service.fetchZebecCardProgram("USA"); if (!programDetails.availablePrograms.length) { throw new Error("No card program is available for this recipient"); } const cardProgramId = programDetails.availablePrograms[0].id; const amount = "25"; const sourceChain = "BINANCE"; const sourceTokenMint = "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"; const quote = await partnerApi.getTopupQuote({ amount, currencyCode: "USD", sourceChain, sourceTokenMint, }); await partnerApi.preflightTopup({ quoteId: quote.id, cardProgramId }); const { orderDetail, receipt } = await service.purchaseCard({ amount, cardProgramId, recipient, quote, token: { symbol: "USDC" }, }); console.log("transaction:", receipt.hash); console.log("order:", orderDetail); ``` `purchaseCard()`: 1. Validates the quote, recipient, supported card program, wallet balance, and contract limits. 2. Approves ERC-20 spending when the existing allowance is too low. 3. Selects a direct purchase or DEX swap-and-buy path from the quote and token metadata. 4. Waits for the on-chain receipt and passes the confirmed purchase to `purchaseApiAdapter.purchaseCard()`. For a non-USDC token, provide its contract address. The quote must include executable swap data from the Partner API. ```ts const result = await service.purchaseCard({ amount: sourceTokenAmount, cardProgramId, recipient, quote, token: { symbol: "VELO", address: "0xf486ad071f3bee968384d2e39e2d8af0fcf6fd46", }, }); ``` The SDK rejects missing swap routes, mismatched tokens or chains, unsafe receivers, and card loads outside the contract limits before token approval. {% hint style="info" %} The older `purchaseCardWithUsdc()` method remains available for backward compatibility. New integrations should use `purchaseCard()`. {% endhint %} ## Solana integration Create `ZebecCardSolanaService` with a configured `ZebecCardV2Service` from `@zebec-network/zebec-card-v2-sdk`. ```ts import { ZebecCardSolanaService } from "@zebec-network/partners-card-sdk"; const service = new ZebecCardSolanaService( cardV2Service, { apiKey, encryptionKey }, { network: "mainnet-beta" }, ); ``` Use `network: "devnet"` together with `sandbox: true` for sandbox testing. The Solana service uses the same `fetchQuote()` and `purchaseCard()` workflow and selects direct or swap execution from the quote and token metadata. ```ts const quote = await service.fetchQuote({ token: "USDC", amount: "25", type: "EXACT_OUT", targetCurrency: "USD", }); const { signature, orderDetail } = await service.purchaseCard({ amount: "25", quote, token: { symbol: "USDC", mintAddress: "<USDC_MINT_ADDRESS>", }, cardProgramId, recipient, }); ``` ## Legacy quote methods `fetchQuote()` and `fetchQuoteForToken()` on the EVM service use the SDK's built-in legacy API client. Use them only if your deployment supports the legacy routes. For the current Partner v1 API, obtain the quote through your authenticated Partner API client and pass it unchanged to `purchaseCard()`. ## Related * [Partner API](/developer-docs/partner-api) — authentication, OTP, card data, quotes, preflight, submission, and status. * [Partner API top-up flow](/developer-docs/partner-api/topup-flow) * [Partners Card SDK package](https://www.npmjs.com/package/@zebec-network/partners-card-sdk) * [Silver, Carbon, and Black card user guides](/zebec-product-information/cards) # Streaming SDK Zebec Streaming SDK - programmable real-time payment streams on Solana, Stellar, and Aleo. The Streaming SDK lets developers create, update, pause, resume, and cancel real-time payment streams on supported blockchains. ## Supported chains Zebec provides Streaming SDKs for the following chains. Select a chain below for installation instructions, configuration details, and the full method reference. | Chain | Status | SDK | Description | | ------------------------------------------------------------------- | --------- | ------------------------------------ | -------------------------------------------------------------- | | [Stellar](/developer-docs/sdks/streaming-sdk/stellar-streaming-sdk) | Available | `@zebec-network/stellar-payroll-sdk` | TypeScript SDK for Soroban smart-contract streams on Stellar. | | [Solana](/developer-docs/sdks/streaming-sdk/solana-streaming-sdk) | Available | `@zebec-network/zebec-stream-sdk` | TypeScript SDK for SPL-token streams on Solana via Anchor. | | [Aleo](/developer-docs/sdks/streaming-sdk/aleo-streaming-sdk) | Available | `@zebec-network/aleo-stream-sdk` | TypeScript SDK for public and private IARC-22 streams on Aleo. | ## Common concepts Across supported chains, the Streaming SDKs share the same high-level model: * **Streams** — on-chain agreements that move tokens from a sender to a receiver over a defined duration. * **Lifecycle management** — create, pause, resume, cancel, withdraw, transfer, and top-up streams. * **Fee configuration** — global protocol fees plus per-sender (tenant) overrides. * **Token whitelisting** — admins control which tokens can be streamed. * **Batch operations** — create, pause, resume, cancel, or top-up many streams in a single transaction (or chunked batch). ## Related * [Enterprise Payroll streaming guide](/zebec-application-suite/enterprise-payroll/streaming-payroll) * [Partner API overview](/developer-docs/partner-api) # Stellar Stellar Streaming SDK - TypeScript SDK for Zebec payment streams on Stellar via Soroban. A TypeScript SDK for interacting with Zebec's Stellar Streaming Contract. This SDK provides a high-level, type-safe interface to create and manage continuous payment streams on the [Stellar](https://stellar.org/) network using [Soroban smart contracts](https://soroban.stellar.org/). ## Overview The Stellar Streaming SDK enables developers to build applications that leverage continuous, programmable token streams on the Stellar network. It wraps the underlying Soroban contract interactions, handling transaction building, simulation, preparation, and submission while exposing strongly-typed, ergonomic APIs. Typical use cases include: * **Payroll** — Stream salaries to employees continuously per second / minute / hour. * **Vesting** — Distribute tokens over time with optional cliffs. * **Subscriptions** — Recurring payments and metered billing. * **Grants & Bounties** — Time-locked, cancelable token distribution. ## Installation Install the package using npm or yarn: ```bash npm install @zebec-network/stellar-payroll-sdk ``` ```bash yarn add @zebec-network/stellar-payroll-sdk ``` ### Peer dependencies The SDK relies on the following runtime dependencies (installed automatically): * [`@stellar/stellar-sdk`](https://www.npmjs.com/package/@stellar/stellar-sdk) `^15.0.1` * [`@zebec-network/core-utils`](https://www.npmjs.com/package/@zebec-network/core-utils) `^1.1.1` * [`bignumber.js`](https://www.npmjs.com/package/bignumber.js) `^11.1.1` ### Requirements * Node.js 18+ recommended * TypeScript 5+ (when consuming from TS projects) ## Quick start ```ts import { StellarStreamingService, type StellarStreamingSDKConfig, type WalletAdapter, type CreateStreamParams, } from "@zebec-network/stellar-payroll-sdk"; import { Networks, Keypair, TransactionBuilder } from "@stellar/stellar-sdk"; // 1. Configure the SDK const config: StellarStreamingSDKConfig = { contractId: "CDWK5GRLUB24FMWLWEAS3NLU2JCDW7T3BMU7HWKGEZEDJRXXESGLQ4YU", networkPassphrase: Networks.TESTNET, rpcUrl: "https://soroban-testnet.stellar.org", }; // 2. Provide a wallet adapter const keypair = Keypair.fromSecret("S..."); const wallet: WalletAdapter = { getPublicKey: async () => keypair.publicKey(), signTransaction: async (txXDR) => { const tx = TransactionBuilder.fromXDR(txXDR, Networks.TESTNET); tx.sign(keypair); return tx.toXDR(); }, signAllTransactions: async (txXDRs) => txXDRs.map((txXDR) => { const tx = TransactionBuilder.fromXDR(txXDR, Networks.TESTNET); tx.sign(keypair); return tx.toXDR(); }), }; // 3. Instantiate the service const service = new StellarStreamingService(config, wallet); // 4. Create a stream const params: CreateStreamParams = { amount: "100", start_time: "0", duration: "3600", cliff_percentage: "0", start_now: true, payroll_run_id: "october-payroll-2026", accrual_frequency: "1", pausable: true, cancelable_by_sender: true, cancelable_by_recipient: false, transferable_by_sender: false, transferable_by_recipient: false, automatic_withdrawal: false, initial_buffer_amount: "0", auto_topup: false, sender_id: "sender-1", receiver_id: "receiver-1", token_price: "10000000", price_expiry: "1893456000", price_signature: "a1b2c3...", token_contract_id: "abcd1234...", xlm_price: "2000000", xlm_price_expiry: "1893456000", xlm_price_signature: "d4e5f6...", }; const payload = await service.createStream( await wallet.getPublicKey(), "GBR...RECEIVER", "0a1b2c...", // streamId (hex-encoded BytesN) "CTOKEN...ADDR", // token contract address params, ); const result = await payload.signAndSubmit(); console.log("Tx hash:", result.txHash); ``` ## Core concepts ### Streams A **stream** is an on-chain agreement to transfer a token amount from a sender to a receiver over a defined duration. Streams can be paused, resumed, canceled, transferred, and topped up depending on the flags set at creation. ### Stream identifiers Stream IDs are 32-byte values passed as **hex-encoded strings**. Stellar's Soroban runtime expects fixed-size byte arrays (`BytesN`) — the SDK converts the provided hex string into the appropriate ScVal automatically. ### Fee model Fees are configured at two layers: 1. **Global config** (set by admin) — applies by default to all streams. 2. **Tenant config** (set by admin, per sender) — overrides global fees for a specific sender. Each layer defines a `platform_fee`, a `base_fee`, a `stream_token_fee`, and a list of `fee_tiers` (amount-banded percentage fees). ### Decimals The SDK automatically converts human-readable amounts to atomic units using the token's on-chain decimals (fetched via `getAssetDecimals`). Inputs like `"100.5"` are scaled correctly for the underlying SAC/token contract. ## SDK methods All write methods return a [`TransactionPayload`](#transactionpayload) that must be signed and submitted. All read methods return parsed, human-readable values directly. The service is constructed as: ```ts new StellarStreamingService(config: StellarStreamingSDKConfig, wallet: WalletAdapter) ``` ### Admin methods These methods configure the global protocol state and require the caller's wallet to match the contract admin. #### `getConfig(caller: string): Promise<Config>` Reads the global protocol configuration: fee recipient, withdraw account, platform fee, base fee, stream token fee, fee tiers, frequencies, whitelisted tokens, the canonical XLM token address, the admin signer, the XLM token contract ID, and whether XLM is accepted as a fee token. #### `setFeeConfig(admin, params, options?): Promise<TransactionPayload>` Sets the protocol-wide fee configuration. The wallet's public key must match `admin`. * `params: SetFeeConfigParams` — recipient, withdraw account, platform/base/stream-token fees (percent), fee tiers, and whether XLM is accepted as a fee token. #### `whitelistTokens(admin, tokens, options?): Promise<TransactionPayload>` Adds a list of token contract addresses to the whitelist of streamable tokens. #### `removeWhitelistedToken(admin, token, options?): Promise<Tr
프로젝트로 돌아가기