Buy US stocks
Let users buy and sell US stocks and funds with the dollars in their account.
Your users can buy shares of Apple, Nvidia, Tesla, the S&P 500 and more than 400 other US stocks and funds with the digital dollars (USDC) in their account. Each share tracks the price of the stock or fund, appears in their portfolio, and can be sold back for dollars.
There is no separate endpoint. Buying a stock uses the exchange endpoint with tokenOut set to the stock, and selling uses the same call with tokenIn set to the stock. Money in Notus lives on a network, like a bank system: your users can pay with dollars they hold on Polygon, Base, Arbitrum, Optimism or Avalanche, and Notus moves the money and places the order in one operation.
Your users can own Apple, Nvidia, Tesla, the S&P 500 and more than 400 other US stocks and ETFs as tokens in their own wallet. The tokens are Ondo Global Markets assets on BNB Smart Chain: each one tracks the price of its stock or ETF and can be sold back for dollars.
There is no separate endpoint. Buying a stock is a swap whose tokenOut is the stock token, and selling is a swap whose tokenIn is the stock token. The user can pay with USDC on Polygon, Base, Arbitrum, Optimism or Avalanche: Notus moves the dollars to BNB Chain and places the order in the same operation.
Find stocks
Call List Tokens to look up a stock's id (address) by ticker, such as NVDA, AAPL or SPY. Filter by network 56 and pick the US stock entry (its symbol ends in on, such as NVDAon, AAPLon, SPYon).
List Tokens returns rwaProvider on every token. Stock tokens have rwaProvider: 'ONDO', a symbol ending in on (NVDAon, AAPLon, SPYon) and chain 56 (BNB Smart Chain).
const { tokens } = await notus.blockchain.listTokens({
search: 'NVDA',
filterByChainId: 56,
filterWhitelist: false,
})
const nvidia = tokens.find((token) => token.rwaProvider === 'ONDO')Add the stocks you want to offer to your project's whitelist in the dashboard.
Buy
Request a quote with walletAddress and toAddress set to the user's account address, tokenIn set to their dollar currency (on network 137, Polygon), tokenOut set to the stock's id (on network 56), and amountIn set to the dollar amount as text ('100' is 100 dollars). Setting gasFeePaymentMethod: 'DEDUCT_FROM_AMOUNT' deducts the network fee from the payment amount.
const USDC_POLYGON = '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359'
const { quotes } = await notus.swaps.createSwapOperation({
walletAddress,
toAddress: walletAddress,
chainIdIn: 137,
chainIdOut: 56,
tokenIn: USDC_POLYGON,
tokenOut: nvidia.address,
amountIn: '100',
payGasFeeToken: USDC_POLYGON,
gasFeePaymentMethod: 'DEDUCT_FROM_AMOUNT',
})
const [quote] = quotesHave the user approve the quote in your app using their login key, then send the approval to executeUserOperation. The quote may include extra confirmations for the stock order itself; pass those fields through in the same call so the user only confirms once in your UI.
A stock purchase can ask the user for up to three signatures, all approved at once in your UI: the operation itself, the stock order, and an allowance on BNB Chain that Notus pays the gas for.
const approve = quote.rwaApproveUserOperation
await notus.userOperations.executeUserOperation({
userOperationHash: quote.userOperationHash,
signature: await signer.signMessage({ message: { raw: quote.userOperationHash } }),
rwaOrderSignature: quote.typedData ? await signer.signTypedData(quote.typedData) : undefined,
rwaApproveUserOperationHash: approve?.userOperationHash,
rwaApproveSignature: approve
? await signer.signMessage({ message: { raw: approve.userOperationHash } })
: undefined,
})The purchase settles in a few minutes: the dollars move, the order fills, and the shares appear in the user's account. Track its status the same way you follow a cross-network transfer.
The purchase settles in a few minutes: the dollars cross to BNB Chain, the order fills, and the stock token lands in the user's wallet. Follow it like any cross-chain swap.
Sell
Selling uses the same call in reverse: tokenIn is the stock's id (on network 56), tokenOut is the dollar currency the user wants back (on their target network), and amountIn is the number of shares to sell ('0.5' is half a share). Have the user approve the quote and submit it with executeUserOperation the same way as a buy.
Selling is the same call the other way around: tokenIn is the stock token on chain 56, tokenOut is the stablecoin the user wants back, on the chain they want it. The quote carries typedData for the order; sign it and send it as rwaOrderSignature.
const { quotes } = await notus.swaps.createSwapOperation({
walletAddress,
toAddress: walletAddress,
chainIdIn: 56,
chainIdOut: 137,
tokenIn: nvidia.address,
tokenOut: USDC_POLYGON,
amountIn: '0.5',
payGasFeeToken: nvidia.address,
gasFeePaymentMethod: 'DEDUCT_FROM_AMOUNT',
})Show positions and returns
Shares appear in the user's portfolio alongside their other balances, with their current dollar value and, when you pass includePnL=true, the profit or loss.
Stock tokens appear in the wallet's portfolio like any token, with their dollar value and, with includePnL=true, the profit or loss.
Good to know
- When there is no quote. While trading is closed or paused, or below the minimum (around $10), the quote comes back without a
userOperationHashand with arevertReasonsaying why. - Quotes are short-lived. A stock quote is valid for a few minutes at most; ask for a new one if the user waits.
- Your fees apply. The fee you set for converting money between networks applies to stock purchases and sales. See Fees.
- When there is no quote. While the venue is closed or paused, or below its minimum (around $10), the quote comes back without a
userOperationHashand with arevertReasonsaying why. - Quotes are short-lived. A stock quote is valid for a few minutes at most; ask for a new one if the user waits.
- Your fees apply. The fee you set for cross-chain swaps applies to stock purchases and sales. See Fees.
How a stock order is routed
- A cross-chain stock trade only goes through venue providers that place the order themselves:
ENSO_1INCH(a 1inch Fusion order on BNB Chain, paid through an Enso and Relay bridge) andPODS_ONDO(Pods' Ondo integration, USDC only). If neither can quote, you get no quote; Notus never falls back to a plain bridge, which would leave the dollars on BNB Chain without an order. - A same-chain trade (paying with a token already on BNB Chain) is an ordinary swap through the normal providers, with no extra signatures.
typedDatais the 1inch Fusion order (EIP-712); send its signature asrwaOrderSignature, or execute fails withMISSING_RWA_ORDER_SIGNATURE.rwaApproveUserOperationis a second, Notus-sponsored user operation on BNB Chain: an exact allowance for the order router, consumed by this order's fill. Sign itsuserOperationHashand sendrwaApproveUserOperationHash+rwaApproveSignature(MISSING_RWA_APPROVE_SIGNATUREotherwise). When itsauthorizationis not null (an EIP-7702 wallet's first operation on BNB Chain), signauthorization.hashand send it asrwaApproveAuthorization.- Wallets: EIP-7702 wallets and Light Account wallets get quotes. Other contract wallets (Kernel, MetaMask Hybrid) can't sign the order yet and get none. See Factories.
toAddressmust be the wallet itself on a buy.- Robinhood Chain (
4663) also has stock tokens. They are not flagged withrwaProviderand trade like any other token on that chain.