pusaka
v1.1.2NFTs on NEAR that each control a native Bitcoin address: buy, lend, borrow, inherit, with caps
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
pusaka_overview
List every Pusaka: owner, BTC verified on NEAR, current sale price, and loan status; plus how many standing loan offers are open and how much NEAR they escrow.
pusaka_inspect
Full due diligence on one Pusaka: verified BTC and its USD value, a live NEAR Intents quote for selling that BTC (exit value), ETH (safe vs at risk), listing premium, loan LTV, APR and how many times the collateral's exit value covers the loan, sign epoch.
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_buy
Buy a listed Pusaka (and the BTC inside). Fails if the current price exceeds max_price_near, the spend cap, or if any signature was requested since inspection.
| Parameter | Type | Description |
|---|---|---|
max_price_near * | number | |
token_id * | string |
pusaka_fund_loan
Fund an open loan request. The Pusaka and its BTC become collateral. Refuses if loan-to-value exceeds max_ltv (default 0.5), or the spend cap.
| Parameter | Type | Description |
|---|---|---|
token_id * | string | |
max_ltv | number |
pusaka_repay_loan
Repay the loan on a Pusaka (usually as the borrower).
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_claim_collateral
As the lender, take the Pusaka (and its BTC) after the due date if the loan wasn't repaid.
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_list
List your Pusaka for sale. Optional floor_near + hours make it a Dutch auction falling to the floor.
| Parameter | Type | Description |
|---|---|---|
price_near * | number | |
token_id * | string | |
floor_near | number | |
hours | number |
pusaka_cancel_listing
Take your Pusaka off the market.
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_request_loan
Ask to borrow NEAR against your Pusaka. It stays locked until cancelled, repaid, or claimed.
| Parameter | Type | Description |
|---|---|---|
days * | number | |
principal_near * | number | |
repay_near * | number | |
token_id * | string |
pusaka_loan_offers
Standing loan offers from lenders: for one Pusaka, or for any Pusaka holding at least N verified sats. The principal is already escrowed in the contract, so the holder can take it instantly with pusaka_accept_loan_offer, also to refinance a funded loan into cheaper or longer terms.
| Parameter | Type | Description |
|---|---|---|
token_id | string |
pusaka_offer_loan
As a lender, post a standing loan offer: escrow principal_near now for one Pusaka (token_id) or for any Pusaka with at least min_verified_sats of light-client-proven BTC. Its holder can accept at once; cancel anytime before. A token offer refuses if loan-to-value would exceed max_ltv (default 0.5) and is void if the Pusaka signs anything (a withdrawal) before acceptance.
| Parameter | Type | Description |
|---|---|---|
days * | number | |
principal_near * | number | |
repay_near * | number | |
max_ltv | number | |
min_verified_sats | integer | |
token_id | string |
pusaka_cancel_loan_offer
Take back your standing loan offer: the escrowed principal and its storage come back to you.
| Parameter | Type | Description |
|---|---|---|
offer_id * | string |
pusaka_accept_loan_offer
As the holder, take a standing loan offer on your Pusaka: the principal arrives at once and the Pusaka becomes collateral until you repay. If the Pusaka already backs a funded loan this refinances it: the offer's principal first pays the current lender in full (you attach any shortfall, capped by max_topup_near, default 0) and the rest comes to you. See pusaka_loan_offers.
| Parameter | Type | Description |
|---|---|---|
offer_id * | string | |
token_id * | string | |
max_topup_near | number |
pusaka_repay_partial
As the borrower, pay part of your loan before it is due; it goes straight to the lender and lowers what you owe. Use pusaka_repay_loan to pay the rest and free the Pusaka.
| Parameter | Type | Description |
|---|---|---|
near * | number | |
token_id * | string |
pusaka_propose_extension
As the lender, offer the borrower more time: move the due date by `days` if they pay `fee_near` (0 for free). The borrower accepts with pusaka_accept_extension before the current due date.
| Parameter | Type | Description |
|---|---|---|
days * | number | |
fee_near * | number | |
token_id * | string |
pusaka_accept_extension
As the borrower, take the lender's proposed extension: pay its fee, the due date moves. Restates the proposal's terms, so a proposal changed in the meantime is refused.
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_gift_link
Turn your Pusaka into a one-use gift link (the contract's NEAR linkdrop, NEP-452): whoever opens it gets the NFT and the Bitcoin it controls, and needs no NEAR account; claiming creates one. Costs 0.25 NEAR. The link IS the gift: share it privately. Needs PUSAKA_ALLOW_OUTFLOWS=1, since the Pusaka leaves you.
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_cancel_gift
Take back an open gift link on your Pusaka: the link stops working and the Pusaka is yours to use again.
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_claim_gift
Claim a Pusaka gift link into this agent's account. Signed with the link's own key, so it costs the agent nothing.
| Parameter | Type | Description |
|---|---|---|
link * | string |
pusaka_prove_deposits
Prove confirmed BTC deposits into a Pusaka through NEAR's on-chain Bitcoin light client, so they count as verified.
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_withdraw_btc
Send BTC out of your Pusaka to a Bitcoin address. The contract builds the transaction, NEAR MPC signs it, this server verifies and broadcasts it.
| Parameter | Type | Description |
|---|---|---|
amount_btc * | number | |
to * | string | |
token_id * | string | |
fee_sats | integer |
pusaka_swap_to_usdc
Testnet: sell BTC out of your Pusaka for USDC on NEAR through NEAR Intents, executed. The contract builds the Bitcoin transaction to a live quote's deposit address, NEAR MPC signs it, and the USDC is paid to this agent's NEAR account; refunds go back to the Pusaka's own Bitcoin address. Runs on Tidepool (1Click's API on testnet, NEAR's defuse verifier; its Bitcoin side is testnet4 with a custodial test relayer), so name the testnet4 tx that funded the Pusaka. Returns once the Bitcoin is sent; follow it with pusaka_swap_status (about one testnet4 block). On Pusaka v2, into_nft: true pays the US…
| Parameter | Type | Description |
|---|---|---|
funding_txid * | string | |
sats * | integer | |
token_id * | string | |
into_nft | boolean |
pusaka_swap_status
Where a NEAR Intents swap stands (pusaka_swap_to_usdc): PENDING_DEPOSIT, KNOWN_DEPOSIT_TX, PROCESSING, SUCCESS, REFUNDED or FAILED, with its NEAR settlement transactions and, once settled, the recipient's USDC balance.
| Parameter | Type | Description |
|---|---|---|
deposit_address * | string |
pusaka_give
Give your Pusaka to another NEAR account: the NFT and everything it controls (BTC, ETH, SOL, its NEAR account, the letter) move in one transaction. Refuses accounts that don't exist, since a Pusaka sent to an account nobody controls is lost.
| Parameter | Type | Description |
|---|---|---|
to * | string | |
token_id * | string |
pusaka_set_heir
Name an heir for your Pusaka: if you stay silent (no check-in) for `days`, the heir can claim the NFT and everything it controls. heir: null removes it. Selling or giving the Pusaka cancels it. Testnet minimum is 10 minutes (0.007 days), mainnet 30 days.
| Parameter | Type | Description |
|---|---|---|
days * | number | |
heir * | string | null | |
token_id * | string |
pusaka_still_here
Check in as the holder of a Pusaka with an heir: restarts the heir's waiting period. Run it on a schedule to keep a Pusaka from passing on while you are around.
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_set_guardians
Add guardians to your Pusaka's will: once you have been silent for the heir's period, `threshold` of these accounts must approve before the heir can claim, and you still get a last waiting period (10 min testnet, 7 days mainnet) to cancel by doing anything. Guardians can only release it to the named heir, never take it. If they never answer, the heir can claim alone after 3 silences. An empty list removes them. Needs an heir first.
| Parameter | Type | Description |
|---|---|---|
guardians * | array | |
threshold * | integer | |
token_id * | string |
pusaka_approve_release
As a named guardian, approve releasing a silent holder's Pusaka to their heir. Possible only after the holder's silence; at the quorum a last waiting period starts, during which any action of the holder voids every approval.
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_claim_inheritance
Claim a Pusaka you were named heir of, once its holder has been silent past claimable_from_ms. Its open listing or loan request is withdrawn; a funded loan's lender comes first.
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_withdraw_eth
Send ETH or USDC out of your Pusaka on an EVM chain (11155111 Sepolia, 84532 Base Sepolia, 421614 Arbitrum Sepolia). The contract builds the EIP-1559 transaction, NEAR MPC signs it with the same key that holds the BTC, this server checks the signature recovers to the Pusaka's address and broadcasts.
| Parameter | Type | Description |
|---|---|---|
amount * | number | |
to * | string | |
token_id * | string | |
chain_id | integer | |
usdc | boolean |
pusaka_withdraw_sol
Send SOL out of your Pusaka (its Ed25519 MPC key is a Solana address). The contract builds a plain System transfer, NEAR MPC signs it, this server broadcasts.
| Parameter | Type | Description |
|---|---|---|
sol * | number | |
to * | string | |
token_id * | string |
pusaka_token_account
Pusaka v2: the NFT's own NEAR account (NEP-616, keyless, answers only to the current holder), its named alias, their balances, what's inside (other Pusakas it holds, with their verified sats, and its USDC: a buyer of this NFT gets all of it), whether the post-quantum (ML-DSA-65) lock is on and open, and any agent's on-chain daily budget.
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_account_send
Pusaka v2: send NEAR out of the NFT's own account (or its named alias) through the contract (account_call). Only the holder, only while the Pusaka isn't listed, pledged or signing; if its post-quantum lock is on, run pusaka_pq_unlock first.
| Parameter | Type | Description |
|---|---|---|
near * | number | |
to * | string | |
token_id * | string | |
alias | boolean |
pusaka_redeem_nbtc
Pusaka v2, holder: turn the nBTC (Omni Bridge) in the NFT's own account back into native Bitcoin, paid to the Pusaka's own Bitcoin address (so it stays with the NFT). Spends one Omni connector coin whole (its rules); returns the plan and the NEAR tx. Near-One's relayer then has NEAR MPC sign the payout. `dry: true` only plans.
| Parameter | Type | Description |
|---|---|---|
token_id * | string | |
dry | boolean |
pusaka_lend_pool
The USDC lending pool (Circle testnet USDC): cash, lent, the BTC price it uses (low side for borrowing, high side for liquidation; null = stale, borrowing and liquidation paused) and every open loan with its debt, loan-to-value and whether it can be liquidated now. With `token_id` (and `contract`), only that Pusaka's loan and the most it could borrow.
| Parameter | Type | Description |
|---|---|---|
contract | string | |
token_id | string |
pusaka_lend_borrow
Holder: borrow the pool's USDC against a Pusaka (up to the pool's max loan-to-value, 79.5% on testnet, of its proven BTC's value at the pool's low price). The NFT goes to the pool, which holds it until repaid; nobody can ask for a Bitcoin signature meanwhile. If the pool refuses (stale price, over the limit, not enough cash) the NFT comes straight back and the refusal reason is returned.
| Parameter | Type | Description |
|---|---|---|
token_id * | string | |
contract | string | |
pusd | number | |
usdc | number |
pusaka_lend_repay
Anyone: repay a pool loan in full (debt now plus a cent; the rest is refunded). The NFT goes back to the borrower; the interest goes to the pool's lenders. The repayer needs the pool's USDC (Circle testnet faucet, network NEAR).
| Parameter | Type | Description |
|---|---|---|
loan_id * | string |
pusaka_lend_liquidate
Anyone: liquidate a pool loan whose loan-to-value reached 80% at the pool's high price, paying max(debt, 95% of the BTC's value). The pool gets the debt, the borrower the rest, the caller the NFT and with it the Bitcoin key. Refused while the loan is healthy or the price is stale.
| Parameter | Type | Description |
|---|---|---|
loan_id * | string |
pusaka_set_agent
Pusaka v2, holder: give an agent account an on-chain daily budget to send NEAR from the NFT's own account (at most `daily_near` per UTC day, only to `only_to` if given, up to 5). The contract enforces it, so a compromised agent loses at most a day's budget. `daily_near: 0` revokes. Ends when the NFT changes hands.
| Parameter | Type | Description |
|---|---|---|
agent * | string | |
daily_near * | number | |
token_id * | string | |
only_to | array |
pusaka_agent_send
Pusaka v2, as the holder's agent: send NEAR from the NFT's own account within the daily budget the holder set on-chain (pusaka_set_agent). The contract refuses anything over budget, to an unlisted receiver, or while the Pusaka is listed, pledged or signing.
| Parameter | Type | Description |
|---|---|---|
near * | number | |
to * | string | |
token_id * | string |
pusaka_sign_in
Pusaka v2, holder: sign in to a website as the NFT. Its own EVM key (the NEAR MPC key that holds its Bitcoin) signs a standard EIP-4361 Sign-In with Ethereum message naming the holder, valid for an hour; returns the message and the 65-byte signature to hand to the site. Only for domains in PUSAKA_SIGN_IN_DOMAINS: a sign-in handed to the wrong party lets it log in as the NFT there.
| Parameter | Type | Description |
|---|---|---|
domain * | string | |
nonce * | string | |
token_id * | string | |
uri * | string | |
chain_id | integer |
pusaka_market_book
The market contract's book: standing bids priced per verified sat (best first, with what each would pay for a given Pusaka), loan offers with no due date, and open perpetual loans with their live debt and refinancing-auction rate.
| Parameter | Type | Description |
|---|---|---|
token_id | string |
pusaka_sell_into_bid
Holder: sell a Pusaka into a standing bid on the market contract (nft_approve with the bid id). The market reads the Pusaka's verified sats on-chain and pays verified_sats x the bid's price per sat; if the token doesn't fit the bid, nothing moves.
| Parameter | Type | Description |
|---|---|---|
bid_id * | string | |
token_id * | string |
pusaka_prove_btc_address
Pusaka v2, holder: the NFT's Bitcoin key (NEAR MPC) signs a BIP-322 proof that it controls the Pusaka's Bitcoin address, over a message the contract prefixes with the token, holder and NEAR block. Returns the address, message and the base64 BIP-322 signature, already verified.
| Parameter | Type | Description |
|---|---|---|
token_id * | string | |
message | string |
pusaka_pq_unlock
Pusaka v2: open the holder's post-quantum lock for ~2 minutes by signing the next unlock message with ML-DSA-65 (verified on-chain by ml_dsa_verify). The key comes from PUSAKA_PQ_SEED_HEX in the server's environment, never from the conversation.
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_withdraw_near
Send NEAR out of your Pusaka's own NEAR account (an implicit account of its Ed25519 MPC key). The contract signs only transactions it builds from it: one Transfer here, nBTC ft_transfer and staking-pool calls elsewhere.
| Parameter | Type | Description |
|---|---|---|
near * | number | |
to * | string | |
token_id * | string |
pusaka_withdraw_nbtc
Send nBTC (Omni Bridge NEP-141) from your Pusaka's own NEAR account. The contract signs one ft_transfer on nbtc.n-bridge.testnet; the receiver must be registered with it.
| Parameter | Type | Description |
|---|---|---|
sats * | integer | |
to * | string | |
token_id * | string |
pusaka_stake_near
Stake, unstake or withdraw NEAR from your Pusaka's own NEAR account at a validator (pools from the official factory, *.pool.f863973.m0). The stake and its rewards stay in that account, so they move with the NFT; nothing leaves the Pusaka. pool "best" picks the active factory pool with the lowest fee. Unstaked NEAR can be withdrawn after about 4 epochs.
| Parameter | Type | Description |
|---|---|---|
action * | string | |
pool * | string | |
token_id * | string | |
near | number |
pusaka_verify_signature
Check a signature someone says comes from a Pusaka, the way a website or exchange would: a 'Sign in as Pusaka #N' message (EIP-4361; pass signature 0x…, and domain = your site) or a BIP-322 proof of its Bitcoin address (pass witness, base64). Checks the signature, that the address is the Pusaka's own NEAR MPC key, that the holder it names still holds it, and (sign-ins) expiry and site. Returns valid plus each check.
| Parameter | Type | Description |
|---|---|---|
message * | string | |
domain | string | |
signature | string | |
witness | string |
pusaka_audit
Independent proof-of-reserves audit of one Pusaka, without trusting the contract's own numbers: asks NEAR's MPC signer which Bitcoin key it derives for this contract and token (must equal the token's key), recomputes verified_sats from the proven deposits minus everything ever signed away, and looks every proven deposit up on Bitcoin itself (confirmed, paying this address, the right amount, and whether it is still unspent). Returns a verdict and each check.
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_paid_audit
The same independent proof-of-reserves audit, bought per call from Pusaka's paid API over x402 (HTTP 402) on NEAR: pays a tiny wNEAR fee (0.001 on testnet) as a gasless NEP-366 ft_transfer that the server settles only after the audit ran. The fee counts against the session spend cap and asks for confirmation; wraps a little NEAR first if the agent holds too little wNEAR. Returns the audit and the NEAR tx of the payment. Needs a full-access key.
| Parameter | Type | Description |
|---|---|---|
token_id * | string | |
url | string | audit endpoint; default PUSAKA_AUDIT_URL or the Pusaka site |
pusaka_contract_trust
Should an agent trust the Pusaka contract itself? Reads from NEAR: the deployed code's sha256 and the reproducible-build source it names (NEP-330), every access key on the contract account (none but one-use gift-link keys means nobody can sign as the contract), whether the code is final (upgrades renounced) or, if not, who can change it (a Sputnik DAO council, its members and vote threshold), the timelock, and any upgrade pending with the time it becomes deployable.
pusaka_history
Provenance of one Pusaka from the contract's own on-chain record: every mint, listing, sale and price, transfer, inheritance, loan (funded, repaid, defaulted, refinanced, extended) and withdrawal, oldest first, plus the chain of holders and the sale prices it has fetched.
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_credit_record
A borrower's on-chain credit record across every Pusaka: loans taken, repaid, defaulted (the lender took the collateral) and still open, read from the contract's history, not from anything the borrower says. Use it before funding a loan request or making an offer.
| Parameter | Type | Description |
|---|---|---|
account_id * | string |
pusaka_loan_watch
Watch every funded Pusaka loan at once: due date, hours left, loan-to-value at live BTC/NEAR prices, and what this agent can do next on each (repay as borrower, claim the collateral as lender once overdue, or a lender's pending extension to accept). Built for an agent that lends or borrows on a schedule.
pusaka_gift_preview
Open a Pusaka gift link without claiming it: who sent it, which Pusaka, and the Bitcoin proven inside, so an agent can check a link is real and still open before claiming. Runs locally; the link never leaves this process.
| Parameter | Type | Description |
|---|---|---|
link * | string |
pusaka_deals
Scan every Pusaka for sale for Bitcoin cheaper than it really sells for: each listing's price now (Dutch auctions fall over time) against a live, solver-signed NEAR Intents quote for selling the verified BTC inside into USDC. A negative discount means the NFT costs less than its BTC's exit value. Sorted best deal first.
| Parameter | Type | Description |
|---|---|---|
max_price_near | number |
pusaka_portfolio
Everything one NEAR account has in Pusaka: the Pusakas it holds and the Bitcoin proven inside them (sats and USD), loans it owes and loans it funded, standing offers it escrowed, and Pusakas that name it as heir. Defaults to this agent's account.
| Parameter | Type | Description |
|---|---|---|
account_id | string |
pusaka_write_letter
Seal a private letter into your Pusaka for whoever holds it next (a seed hint, a story, instructions for an heir). The key comes from NEAR's MPC network through the contract (confidential key derivation): no server, not even ours, ever sees it, and only the current holder can ask for it. The sealed text is stored on-chain with the NFT. Up to ~1,400 characters; costs 0.01 NEAR of storage.
| Parameter | Type | Description |
|---|---|---|
text * | string | |
token_id * | string |
pusaka_read_letter
Open the sealed letter inside a Pusaka you hold: the contract asks NEAR's MPC network for the letter's key on your behalf (refused to anyone who isn't the holder), and it is decrypted here, in this process.
| Parameter | Type | Description |
|---|---|---|
token_id * | string |
pusaka_mint
Mint a new Pusaka. Returns its id and native Bitcoin address.