/** * Transaction action factories. * * Provides low-level, type-safe helpers for creating NEAR transaction actions. * Most applications should use {@link TransactionBuilder} rather than calling * these functions directly; they are exported for advanced and custom tooling. */ import type { AccessKeyPermissionBorsh, AddKeyAction, ClassicAction, CreateAccountAction, DelegateV2Action, DeleteAccountAction, DeleteKeyAction, DeployContractAction, DeployGlobalContractAction, DeterministicStateInitAction, FunctionCallAction, FunctionCallPermissionBorsh, NonDelegateActionBorsh, SignedDelegateAction, StakeAction, TransactionNonceBorsh, TransferAction, TransferToGasKeyAction, UseGlobalContractAction, WithdrawFromGasKeyAction } from "./schema.js"; import type { Ed25519PublicKey, GlobalContractReference, PublicKey, Secp256k1PublicKey, Signature } from "./types.js"; /** * Delegate action for NEP-366 meta-transactions. * * Represents a set of classic actions signed by one account to be executed * by another (typically a relayer). */ export declare class DelegateAction { senderId: string; receiverId: string; actions: ClassicAction[]; nonce: bigint; maxBlockHeight: bigint; publicKey: PublicKey; constructor(senderId: string, receiverId: string, actions: ClassicAction[], nonce: bigint, maxBlockHeight: bigint, publicKey: PublicKey); } /** * Delegate action V2 for gas-key meta-transactions (NEP-611 / NEAR 2.13). * * Like {@link DelegateAction} but its `nonce` is a {@link TransactionNonceBorsh} * (so it can target a gas key's nonce slot), and it is signed under a DISTINCT * NEP-461 domain tag — a V1 delegate signature is never valid for a V2 action. * The `actions` are full (non-delegate) actions and must already be in * Borsh-ready form (as returned by the action factories). */ export declare class DelegateActionV2 { senderId: string; receiverId: string; actions: NonDelegateActionBorsh[]; nonce: TransactionNonceBorsh; maxBlockHeight: bigint; publicKey: PublicKey; constructor(senderId: string, receiverId: string, actions: NonDelegateActionBorsh[], nonce: TransactionNonceBorsh, maxBlockHeight: bigint, publicKey: PublicKey); /** * Convert to the Borsh-ready shape consumed by * {@link serializeDelegateActionV2} and {@link signedDelegateV2}. * @internal */ toBorsh(): { senderId: string; receiverId: string; actions: NonDelegateActionBorsh[]; nonce: { nonce: { nonce: bigint; }; } | { gasKeyNonce: { nonce: bigint; nonceIndex: number; }; }; maxBlockHeight: bigint; publicKey: { ed25519Key: { data: number[]; }; } | { secp256k1Key: { data: number[]; }; } | { mlDsa65Key: { data: number[]; }; }; }; } /** * Create a transfer action. * * @param deposit - Amount in yoctoNEAR as bigint. */ export declare function transfer(deposit: bigint): TransferAction; /** * Create a function call action. * * @param methodName - Contract method name. * @param args - Serialized arguments as bytes. * @param gas - Gas attached (raw units). * @param deposit - Attached deposit in yoctoNEAR. */ export declare function functionCall(methodName: string, args: Uint8Array, gas: bigint, deposit: bigint): FunctionCallAction; /** * Create an account creation action. */ export declare function createAccount(): CreateAccountAction; /** * Create a delete account action. */ export declare function deleteAccount(beneficiaryId: string): DeleteAccountAction; /** * Create a deploy contract action. * * @param code - WASM bytes of the contract to deploy. */ export declare function deployContract(code: Uint8Array): DeployContractAction; /** * Create a stake action. * * @param amount - Amount to stake in yoctoNEAR. * @param publicKey - Validator public key. */ export declare function stake(amount: bigint, publicKey: Ed25519PublicKey): { stake: { stake: bigint; publicKey: { ed25519Key: { data: number[]; }; }; }; }; export declare function stake(amount: bigint, publicKey: Secp256k1PublicKey): { stake: { stake: bigint; publicKey: { secp256k1Key: { data: number[]; }; }; }; }; export declare function stake(amount: bigint, publicKey: PublicKey): StakeAction; /** * Create an add key action. * * @param publicKey - Public key to add. * @param permission - Access key permission in Borsh format. */ export declare function addKey(publicKey: Ed25519PublicKey, permission: AccessKeyPermissionBorsh): { addKey: { publicKey: { ed25519Key: { data: number[]; }; }; accessKey: { nonce: bigint; permission: AccessKeyPermissionBorsh; }; }; }; export declare function addKey(publicKey: Secp256k1PublicKey, permission: AccessKeyPermissionBorsh): { addKey: { publicKey: { secp256k1Key: { data: number[]; }; }; accessKey: { nonce: bigint; permission: AccessKeyPermissionBorsh; }; }; }; export declare function addKey(publicKey: PublicKey, permission: AccessKeyPermissionBorsh): AddKeyAction; /** * Create a delete key action. * * @param publicKey - Public key to remove. */ export declare function deleteKey(publicKey: Ed25519PublicKey): { deleteKey: { publicKey: { ed25519Key: { data: number[]; }; }; }; }; export declare function deleteKey(publicKey: Secp256k1PublicKey): { deleteKey: { publicKey: { secp256k1Key: { data: number[]; }; }; }; }; export declare function deleteKey(publicKey: PublicKey): DeleteKeyAction; /** * Fund a gas key's prepaid balance. * * Gas keys are access keys that carry a prepaid balance used to pay for gas, so * the account's main balance is not touched when the key signs transactions. * * @param publicKey - The gas key to fund. * @param deposit - Amount in yoctoNEAR to add to the gas key balance. */ export declare function transferToGasKey(publicKey: PublicKey, deposit: bigint): TransferToGasKeyAction; /** * Withdraw NEAR from a gas key's balance back to the account. * * @param publicKey - The gas key to withdraw from. * @param amount - Amount in yoctoNEAR to move from the gas key balance to the account. */ export declare function withdrawFromGasKey(publicKey: PublicKey, amount: bigint): WithdrawFromGasKeyAction; /** * Build a `GasKeyFullAccess` permission in Borsh format. * * A gas key with full access can sign any action, paying for gas from its * prepaid balance. The key is added with `balance: 0`; fund it afterwards with * {@link transferToGasKey}. * * @param numNonces - Number of independent nonce slots to allocate (1..=1024), * enabling that many transactions to be signed in parallel by this key. */ export declare function gasKeyFullAccess(numNonces: number): AccessKeyPermissionBorsh; /** * Build a `GasKeyFunctionCall` permission in Borsh format. * * Like {@link gasKeyFullAccess} but restricted to function calls on a single * contract (and optionally a set of methods), the same way a regular function * call access key is restricted. * * A gas function-call key must NOT carry an allowance — the protocol rejects an * `AddKey` with one. The `allowance` field is therefore forced to `null`, and a * non-null value (e.g. from a JS caller) is rejected with a clear error rather * than silently producing an invalid permission. * * @param numNonces - Number of independent nonce slots to allocate (1..=1024). * @param functionCall - The function call restriction (receiver, methods). Any * `allowance` must be `null`/omitted. */ export declare function gasKeyFunctionCall(numNonces: number, functionCall: FunctionCallPermissionBorsh): AccessKeyPermissionBorsh; /** * Publish a global contract that can be reused by multiple accounts. * * Global contracts are deployed once and referenced by multiple accounts, * saving storage costs. Two modes are available: * * - **"account" (default)** - Contract is identified by the signer's account ID. The signer * can update the contract later, and all accounts using it will automatically * use the updated version. Use this when you need to push updates to users. * * - **"hash"** - Contract is identified by its code hash. This creates * an immutable contract that cannot be updated. Other accounts reference it by * the hash. Use this when you want guaranteed immutability. * * @param code - The compiled contract code bytes (WASM) * @param options - Optional configuration * @param options.identifiedBy - How the contract is identified and referenced: * - `"account"` (default): Updatable by signer, identified by signer's account ID * - `"hash"`: Immutable, identified by code hash * @returns DeployGlobalContractAction * * @example * ```typescript * // Publish updatable contract (identified by your account) - default * publishContract(contractCode) * publishContract(contractCode, { identifiedBy: "account" }) * * // Publish immutable contract (identified by its hash) * publishContract(contractCode, { identifiedBy: "hash" }) * ``` */ export declare function publishContract(code: Uint8Array, options?: { identifiedBy?: "hash" | "account"; }): DeployGlobalContractAction; /** * Deploy a contract to this account from previously published code in the global registry * * @param reference - Reference to the published contract, either: * - { codeHash: Uint8Array | string } - Reference by code hash (Uint8Array or base58 string) * - { accountId: string } - Reference by the account that published it * @returns UseGlobalContractAction * * @example * ```typescript * // Deploy from code hash (Uint8Array) * deployFromPublished({ codeHash: hashBytes }) * * // Deploy from code hash (base58 string) * deployFromPublished({ codeHash: "5FzD8..." }) * * // Deploy from account ID * deployFromPublished({ accountId: "contract-publisher.near" }) * ``` */ export declare function deployFromPublished(reference: GlobalContractReference): UseGlobalContractAction; /** * Create a signed delegate action for meta-transactions */ export declare function signedDelegate(delegateAction: DelegateAction, signature: Signature): SignedDelegateAction; /** * Create a V2 signed delegate action (gas-key meta-transactions, NEAR 2.13). * * Wraps the signed V2 payload in `Action::DelegateV2` (discriminant 14). The * signature must have been produced over {@link serializeDelegateActionV2} of * the same delegate action. */ export declare function signedDelegateV2(delegateAction: DelegateActionV2, signature: Signature): DelegateV2Action; /** * Options for creating a StateInit action */ export interface StateInitOptions { /** * Code reference - either a code hash or account ID that published the global contract */ code: { codeHash: string | Uint8Array; } | { accountId: string; }; /** * Initial key-value pairs to populate in the contract's storage * Keys and values should be Borsh-serialized bytes */ data?: Map; /** * Amount to attach for storage costs (in yoctoNEAR) */ deposit: bigint; } /** * Create a StateInit action for deploying a contract with a deterministically derived account ID. * * This enables NEP-616 deterministic AccountIds where the account ID is derived from: * `"0s" + hex(keccak256(borsh(state_init))[12..32])` * * @param options - StateInit configuration * @returns DeterministicStateInitAction * * @example * ```typescript * // Deploy from a published global contract by account ID * stateInit({ * code: { accountId: "publisher.near" }, * deposit: BigInt("1000000000000000000000000"), // 1 NEAR * }) * * // Deploy from a code hash * stateInit({ * code: { codeHash: hashBytes }, * deposit: BigInt("1000000000000000000000000"), * }) * ``` */ export declare function stateInit(options: StateInitOptions): DeterministicStateInitAction; //# sourceMappingURL=actions.d.ts.map