import * as _shared_clients_developer_controlled_wallets from '../../types/clients/developer-controlled-wallets'; import { Wallet, Balance, ScaCore } from '../../types/clients/developer-controlled-wallets'; import * as axios from 'axios'; import * as _shared_core from '../../types/clients/core'; import { Common, ClientParams as ClientParams$1, FeeConfiguration as FeeConfiguration$1, WithIdempotencyKey, Pagination } from '../../types/clients/core'; import * as _shared_clients_smart_contract_platform from '../../types/clients/smart-contract-platform'; import { AbiParametersInner, Blockchain, FeeLevel, ContractInputType, ContractStatus, ReadContractStateData } from '../../types/clients/smart-contract-platform'; import { ContractExecutionBlockchain, Blockchain as Blockchain$1, CircleDeveloperControlledWalletsClient, FeeLevel as FeeLevel$1, GetWalletsWithBalancesInput, SignTypedDataInput, SignTransactionInput, TransactionFee } from '@circle-fin/developer-controlled-wallets'; export { CreateContractExecutionTransactionInput, CreateTransferTransactionInput as CreateTransactionInput } from '@circle-fin/developer-controlled-wallets'; type EOAWalletWithBalances = Wallet & { accountType: 'EOA'; tokenBalances: Balance[]; }; type SCAWalletWithBalances = Wallet & { accountType: 'SCA'; scaCore: ScaCore; tokenBalances: Balance[]; }; type WalletWithBalances = EOAWalletWithBalances | SCAWalletWithBalances; /** * Represents a primitive JSON value. */ type JsonPrimitive = string | number | boolean | null; /** * Represents any valid JSON value including nested objects and arrays. */ type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue; }; /** * Type of the data that is stored. */ type StoredData = { /** * The publicKey that is associated to the entity. */ publicKey: string; }; interface Config { /** * Your configured entity secret. */ entitySecret: string; } type ClientParams = ClientParams$1 & Config; /** * Represents the input parameters for deploying a contract. */ type DeployContractInput = { /** * The contract's name. */ name: string; /** * The description for the contract. */ description?: string; /** * Unique identifier of the wallet that will deploy the contract. */ walletId: string; /** * The contract's ABI in a JSON stringified format. */ abiJson: string; /** * Bytecode of the contract being deployed. */ bytecode: string; /** * The blockchain on which the contract will be deployed. */ blockchain: Blockchain; /** * A list of arguments to pass to the contract's constructor function. Must be an empty array if there are no constructor parameters. */ constructorParameters?: any[]; /** * Configuration that determines the fees that will be paid. */ fee: FeeConfiguration$1; /** * The reference ID for the operation, to ensure idempotency. */ refId?: string; } & WithIdempotencyKey & Common; /** * Represents the input for deploying a contract. */ type EstimateDeploymentFeeInput = { /** * Blockchain is the blockchain to deploy onto. */ blockchain?: Blockchain; /** * Bytecode of the contract being deployed. */ bytecode: string; /** * The contract's ABI in a JSON stringified format. */ abiJson?: string; /** * Signature of the constructor if the contract has one. Constructor() by default. */ constructorSignature?: string; /** * A list of arguments to pass to the contract\'s constructor function. Must be an empty array if there are no constructor parameters. */ constructorParameters?: Array; /** * The source address of the transaction. */ sourceAddress?: string; /** * Unique identifier of the wallet that will deploy the contract. */ walletId?: string; } & Common; /** * Represents the input for fetching a contract. */ type GetContractInput = { /** * The contract's ID. */ id: string; } & Common; /** * Represents the input for deploying a contract. */ type ImportContractInput = { /** * The contract's name. */ name: string; /** * The description for a contract. */ description?: string; /** * Address is the address of the contract to be imported. */ address: string; /** * Blockchain is the blockchain to deploy onto. */ blockchain: Blockchain; /** * If true, refreshes the contract's ABI and source code from the blockchain explorer for contracts that have since been verified on-chain. */ refreshVerification?: boolean; } & WithIdempotencyKey & Common; /** * Represents the input for fetching all contracts. */ type ListContractsInput = { /** * Filter by blockchain. */ blockchain?: Blockchain; /** * Filter contracts by input type. */ contractInputType?: ContractInputType; /** * Filter contracts by deployer address. */ deployerAddress?: string; /** * Filter contracts by name. */ name?: string; /** * Filter contracts by status. */ status?: ContractStatus; } & Pagination & Common; /** * Represents the input parameters for deploying a contract. */ type QueryContractInput = { /** * The contract ABI function signature or `callData` field is required for interacting with the smart contract. The ABI function signature cannot be used simultaneously with `callData`. e.g. Burn(uint256). */ abiFunctionSignature?: string; /** * The contract ABI function signature parameters for executing the contract interaction. Supported parameter types include string, integer, boolean, and array. These parameters should be used exclusively with the abiFunctionSignature and cannot be used with `callData`. */ abiParameters?: Array; /** * The contract's ABI in a JSON stringified format. */ abiJson?: string; /** * Address of the contract to be queried. */ address: string; /** * Blockchain of the contract to be queried. */ blockchain: Blockchain; /** * CallData is input data that encodes method and parameters. */ callData?: string; /** * FromAddress is the address that will populate msg.sender in the contract call. */ fromAddress?: string; } & Common; /** * Represents the input for updating contract off-chain properties. */ type UpdateContractInput = { /** * The contract's ID. */ id: string; /** * The contract's name. */ name?: string; /** * The description for a contract. */ description?: string; /** * The archive state of the contract. If true, the contract will not be visible in your dashboard. */ archived?: boolean; } & Common; /** * Represents the input parameters for deploying a contract using a template. */ type DeployContractTemplateInput = { /** * The template's ID. */ id: string; /** * The blockchain on which the contract will be deployed. */ blockchain: Blockchain; /** * The wallet's ID that will be used as the source for the contract deployment. */ walletId: string; /** * The contract's name. */ name: string; /** * The description for the contract. */ description?: string; /** * JSON object that contains the template deployment parameters used to initialize the contract(s) on-chain. */ templateParameters?: Record; /** * Configuration that determines the fees that will be paid. */ fee: FeeConfiguration$1; /** * The reference ID for the operation, to ensure idempotency. */ refId?: string; } & WithIdempotencyKey & Common; /** * Represents the input for deploying a contract using a template. */ type EstimateContractTemplateDeploymentFeeInput = { /** * The template's ID. */ id: string; /** * The blockchain on which the contract will be deployed. */ blockchain: Blockchain; /** * The source address of the transaction. */ sourceAddress?: string; /** * JSON object that contains the template deployment parameters used to initialize the contract(s) on-chain. */ templateParameters: Record; /** * Unique identifier of the wallet that will deploy the contract. */ walletId?: string; } & Common; /** * Represents the input for fetching event monitors. */ type ListEventMonitorsInput = { contractAddress?: string; blockchain?: Blockchain; eventSignature?: string; } & Pagination & Common; /** * Represents the input for creating an event monitor. */ type CreateEventMonitorInput = { /** * Create a new event monitor based on the provided blockchain. */ blockchain: Blockchain; /** * The on-chain address of this contract. */ contractAddress: string; /** * The specific event to which you want to subscribe. Please ensure no spaces are included. */ eventSignature: string; } & WithIdempotencyKey & Common; /** * Represents the input for updating an event monitor. */ type UpdateEventMonitorInput = { /** * Event Monitor ID. */ id: string; /** * Indicates whether the event monitor should be active (true) or inactive (false). */ isEnabled: boolean; } & Common; /** * Represents the input for deleting a event monitor. */ type DeleteEventMonitorsInput = { /** * Event Monitor ID. */ id: string; } & Common; /** * Represents the input for listing all event logs. */ type ListEventLogsInput = { contractAddress?: string; blockchain?: Blockchain; } & Pagination & Common; /** * A class-based client for Circle's Smart Contract Platform. * All operations are available as class methods. * @example * ``` * import { CircleSmartContractPlatformClient } from '@circle-fin/smart-contract-platform' * * const client = new CircleSmartContractPlatformClient({ * apiKey: 'YOUR_KEY', * entitySecret: 'YOUR_SECRET', * }) * * const response = await client.listContracts() * console.log(response.data?.contracts) * ``` */ declare class CircleSmartContractPlatformClient { private readonly params; /** * Creates an instance of CircleSmartContractPlatformClient. * @param config - API key, entity secret, optional baseUrl. */ constructor(config: ClientParams); /** * Deploy a smart contract on a specified blockchain using the contract's ABI and bytecode. The deployment will originate from one of your Circle Programmable Wallets. * @example * ``` * const response = await client.deployContract({ * name: 'First Contract', * description: 'My first hello world contract', * blockchain: 'ETH-SEPOLIA', * walletId: '004735f6-d9fc-44f8-933c-672cdf3d240d', * abiJson: '[\n\t{\n\t\t\'inputs\': [],\n\t\t\'stateMutability\': \'nonpayable\',\n\t\t\'type\': \'constructor\'\n\t},\n\t...', * bytecode: '0x60806040523480156200001157600080fd5b50604051806040...', * constructorParameters: ['TICK',10000], * fee: { * type: 'level', * config: { * feeLevel: 'HIGH', * }, * }, * }) * console.log(response.data) * ``` * @category Contracts */ deployContract(input: DeployContractInput): Promise<_shared_core.TrimDataResponse<_shared_clients_smart_contract_platform.ContractDeployment>>; /** * Estimates the network fee for deploying a smart contract on a specified blockchain, given the contract bytecode. * @example * ``` * const response = await client.estimateContractDeploymentFee({ * sourceAddress: '0x1bf9ad0cc2ad298c69a2995aa806ee832788218c', * blockchain: 'MATIC-AMOY', * bytecode: '0x60806040523480156200001157600080fd5b50604051806040...', * constructorSignature: 'constructor(string ticker, uint256 totalSupply)', * constructorParameters: [ 'TICK', 10000], * }) * console.log(response.data) * ``` * @category Contracts */ estimateContractDeploymentFee(input: EstimateDeploymentFeeInput): Promise<_shared_core.TrimDataResponse<_shared_clients_smart_contract_platform.FeeEstimation>>; /** * Add an existing smart contract to your library of contracts. It also can be done in the Web3 Services Console. * @example * ``` * const response = await client.importContract({ * name: 'testContract', * description: 'testDescription', * address: '0xa51c9c604b79a0fadbfed35dd576ca1bce71da0a', * blockchain: 'ETH-SEPOLIA', * }) * console.log(response.data) * ``` * @category Contracts */ importContract(input: ImportContractInput): Promise<_shared_core.TrimDataResponse<_shared_clients_smart_contract_platform.ContractResponse>>; /** * Retrieves a single contract that you've imported or deployed. You need to provide the contract's ID instead of the on-chain address. * @example * ``` * const response = await client.getContract({ * id: '39c7146d-d240-45c3-9402-8d817a633b17', * }) * console.log(response.data) * ``` * @category Contracts */ getContract(input: GetContractInput): Promise<_shared_core.TrimDataResponse<_shared_clients_smart_contract_platform.ContractResponse>>; /** * Fetch a list of contracts that you've imported and/or deployed. * @example * ``` * const response = await client.listContracts({ * blockchain: 'MATIC-AMOY', * status: 'COMPLETE', * contractInputType: 'IMPORT', * }) * console.log(response.data) * ``` * @category Contracts */ listContracts(input?: ListContractsInput): Promise<_shared_core.TrimDataResponse<_shared_clients_smart_contract_platform.Contracts>>; /** * Update the off-chain properties, such as description, of a contract that you've imported or deployed. * * This method uses the contract's ID instead of the on-chain address. * @example * ``` * const response = await client.updateContract({ * id: 'c4d1da72-111e-4d52-bdbf-2e74a2d803d5', * archived: true, * }) * console.log(response.data) * ``` * @category Contracts */ updateContract(input: UpdateContractInput): Promise<_shared_core.TrimDataResponse<_shared_clients_smart_contract_platform.ContractResponse>>; /** * Query the state of a contract by providing the address and blockchain. * @example * ``` * const response = await client.queryContract({ * blockchain: "MATIC-AMOY", * address: "0xfea0e6a371a0eb204dbfae2ee38eeedeebe15ed7", * callData: "0x0000000000000000000000000000000000000000000000000000000000000000", * }) * console.log(response.data) * ``` * @category Contracts */ queryContract(input: QueryContractInput): Promise<_shared_core.TrimDataResponse<_shared_clients_smart_contract_platform.ReadContractState>>; /** * Deploy a smart contract using a template. * @example * ``` * const response = await client.deployContractTemplate({ * id: 'cf930871-bc29-43f0-9abb-0af6e66bd8db', * blockchain: 'MATIC-AMOY', * templateParameters: {}, * walletId: '3962046c-4bd3-43ca-bb84-0c8f7dbfa798', * fee: { * type: 'level', * config: { * feeLevel: 'HIGH', * }, * }, * name: 'Contract name', * }) * console.log(response.data) * ``` * @category Contract Templates */ deployContractTemplate(input: DeployContractTemplateInput): Promise<_shared_core.TrimDataResponse<_shared_clients_smart_contract_platform.TemplateContractDeployment>>; /** * Estimate the fee required to deploy contract by template. * @example * ``` * const response = await client.estimateContractTemplateDeploymentFee({ * id: "cf930871-bc29-43f0-9abb-0af6e66bd8db", * blockchain: "MATIC-AMOY", * sourceAddress: "0xfea0e6a371a0eb204dbfae2ee38eeedeebe15ed7", * templateParameters: {}, * }) * console.log(response.data) * ``` * @category Contract Templates */ estimateContractTemplateDeploymentFee(input: EstimateContractTemplateDeploymentFeeInput): Promise<_shared_core.TrimDataResponse<_shared_clients_smart_contract_platform.FeeEstimation>>; /** * Create a new event monitor based on the provided blockchain, contract address, and event signature. * @example * ``` * const response = await client.createEventMonitor({ * blockchain: 'ETH', * contractAddress: '0x71C7656EC7ab88b098defB751B7401B5f6d8976F', * eventSignature: 'Transfer(address,address,uint256)', * }) * console.log(response.data) * ``` * @category Event Monitors */ createEventMonitor(input: CreateEventMonitorInput): Promise<_shared_core.TrimDataResponse<_shared_clients_smart_contract_platform.EventMonitorResponse>>; /** * Fetch a list of event monitors, optionally filtered by blockchain, contract address, and event signature. * @example * ``` * const response = await client.listEventMonitors() * console.log(response.data) * ``` * @category Event Monitors */ listEventMonitors(input: ListEventMonitorsInput): Promise<_shared_core.TrimDataResponse<_shared_clients_smart_contract_platform.EventMonitors>>; /** * Update an existing event monitor given its ID. * @example * ``` * const response = await client.updateEventMonitor({ * id: 'c4d1da72-111e-4d52-bdbf-2e74a2d803d5', * isEnabled: true, * }) * console.log(response.data) * ``` * @category Event Monitors */ updateEventMonitor(input: UpdateEventMonitorInput): Promise<_shared_core.TrimDataResponse<_shared_clients_smart_contract_platform.EventMonitorResponse>>; /** * Delete an existing event monitor given its ID. * @example * ``` * const response = await client.deleteEventMonitor({ * id: 'c4d1da72-111e-4d52-bdbf-2e74a2d803d5', * }) * console.log(response.data) * ``` * @category Event Monitors */ deleteEventMonitor(input: DeleteEventMonitorsInput): Promise>; /** * Fetch all event logs, optionally filtered by blockchain and contract address. * @example * ``` * const response = await client.listEventLogs() * console.log(response.data) * ``` * @category Event Monitors */ listEventLogs(input: ListEventLogsInput): Promise<_shared_core.TrimDataResponse<_shared_clients_smart_contract_platform.EventLogs>>; } type Chain = { readonly id: number; readonly blockchainId: ContractExecutionBlockchain; readonly testnet: boolean; }; /** * Every EVM chain DCW currently supports, derived from `EvmBlockchainId`. * * Frozen so `resolveChain` can hand back a stable reference without callers * (or a future `Provider`) being able to mutate shared state. */ declare const SUPPORTED_CHAINS: readonly Chain[]; /** Numeric EVM chain id or `Blockchain` code. */ type ChainIdentifier = number | Blockchain$1; /** Resolve chain id or `Blockchain` code to a `Chain`; `undefined` if unsupported. */ declare function resolveChain(chain: ChainIdentifier): Chain | undefined; /** `0x`-prefixed hex string. Used for transaction hashes, addresses, and other hex-encoded values. */ type Hex = `0x${string}`; /** * Decimal string of native-token units (e.g. `'0.5'` ETH, `'1000000000000000000'` * wei). Circle's DCW API expresses amounts as decimal strings rather than the * hex wei values EIP-1193 uses, so the Provider formats between the two. */ type NativeUnits = `${number}`; /** * JSON-RPC transaction request; numeric fields are `QUANTITY`-encoded * (hex strings) and byte fields are `DATA`-encoded per the Ethereum * JSON-RPC spec. EIP-1193 inherits this encoding via its JSON-RPC * transport surface. * @see https://ethereum.org/en/developers/docs/apis/json-rpc/#hex-value-encoding — `QUANTITY` / `DATA` encoding rules * @see https://eips.ethereum.org/EIPS/eip-1193 — the `request({ method, params })` transport surface */ type RpcTransactionRequest = { from?: Hex; to?: Hex; value?: Hex; data?: Hex; gas?: Hex; gasPrice?: Hex; maxFeePerGas?: Hex; maxPriorityFeePerGas?: Hex; nonce?: Hex; chainId?: Hex; type?: Hex; }; /** Minimal EIP-1193 provider surface: anything with `.request({ method, params? })`. */ type EIP1193Provider = { request: (args: { method: string; params?: unknown[]; }) => Promise; }; type FeeConfiguration = FeeConfiguration$1; /** Default `request` allowlist. Subset via `supportedMethods` to restrict further. */ declare const DEFAULT_SUPPORTED_METHODS: readonly ["eth_chainId", "eth_getBalance", "eth_call", "eth_sendTransaction", "eth_estimateGas", "eth_gasPrice", "eth_maxPriorityFeePerGas", "eth_signTypedData_v4", "eth_signTransaction", "wallet_sendTransaction"]; type SupportedMethod = (typeof DEFAULT_SUPPORTED_METHODS)[number]; /** Options for the EIP-1193 provider. Unsupported methods delegate to `fallback` or throw `MethodNotFoundRpcError`. */ type ProviderOptions = { /** API key. */ apiKey: string; /** Entity secret. */ entitySecret: string; /** API base URL. Defaults to `https://api.circle.com`. */ baseUrl?: string; /** Optional User-Agent header. */ userAgent?: string; /** Numeric chain id (e.g. `1`, `137`) or `Blockchain` code (e.g. `'ETH'`, `'MATIC'`). Unsupported values throw `UnsupportedChainError`. */ chain: ChainIdentifier; /** Polling timeout (ms) for `txHash`. Omit for no timeout. */ txPollingTimeout?: number; /** Poll interval (ms) for `getTransaction`. Defaults to 1000. */ txPollingInterval?: number; /** Buffer applied to each estimate tier (default 0.05). `0` disables. */ estimateFeeBuffer?: number; /** EIP-1193 provider invoked on `MethodNotFoundRpcError`. */ fallback?: EIP1193Provider; /** Methods `request` will dispatch. Defaults to all built-in `eth_*` handlers. */ supportedMethods?: readonly SupportedMethod[]; /** Fee level when the caller omits fee fields. Defaults to `'HIGH'`. */ defaultFeeLevel?: FeeLevel$1; }; declare class Provider { protected readonly sdk: CircleDeveloperControlledWalletsClient; protected readonly scp: CircleSmartContractPlatformClient; protected readonly txPollingInterval: number; protected readonly estimateFeeBuffer: number; protected readonly defaultFeeLevel: FeeLevel$1; protected readonly chain: Chain; private readonly fallback?; private readonly requestDispatch; protected txPollingTimeout?: number; constructor(opts: ProviderOptions); get defaultSignal(): AbortSignal | undefined; /** DCW client for operations outside the EIP-1193 surface (wallet sets, derive, list, etc.). */ getSdk(): CircleDeveloperControlledWalletsClient; /** * Both underlying clients (DCW + SCP) for operations outside the EIP-1193 * surface. Will be deprecated once DCW covers `queryContract` and SCP no * longer needs to be exposed. */ getSdks(): { sdk: CircleDeveloperControlledWalletsClient; scp: CircleSmartContractPlatformClient; }; /** Dispatch to the matching `eth_*` handler; route `MethodNotFoundRpcError` to `fallback` when configured. */ request({ method, params, }: { method: string; params?: unknown[]; }): Promise; protected eth_chainId(): Hex; protected eth_getBalance(address: Hex, blockTag?: string): Promise; protected eth_call(params: RpcTransactionRequest, blockIdentifier?: string): Promise; protected eth_sendTransaction(params: RpcTransactionRequest): Promise; /** Alias for `eth_sendTransaction` (EIP-5792-adjacent callers use this for some tx shapes). */ protected wallet_sendTransaction(params: RpcTransactionRequest): Promise; /** * Estimate gas. `from` is optional; defaults to the zero address (Geth / viem convention). * * Contract-execution estimates are sender-aware — supply `from` for accuracy when * the contract reads `msg.sender`. Transfer estimates are sender-agnostic. * @see https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_estimategas */ protected eth_estimateGas(params: RpcTransactionRequest, blockIdentifier?: string): Promise; /** Effective gas price for `defaultFeeLevel`. Keeps clients above per-chain priority-fee floors. */ protected eth_gasPrice(): Promise; /** `priorityFee` of `defaultFeeLevel`. Keeps clients above per-chain priority-fee floors. */ protected eth_maxPriorityFeePerGas(): Promise; protected eth_signTypedData_v4(address: Hex, message: string): Promise; protected eth_signTransaction(params: RpcTransactionRequest & { chainId?: Hex; }): Promise; protected circle_queryContract(params: QueryContractInput): Promise; protected circle_getWalletsWithBalances(params: GetWalletsWithBalancesInput): Promise; protected circle_signTypedData(params: SignTypedDataInput): Promise<_shared_clients_developer_controlled_wallets.SignatureResponseData>; protected circle_signTransaction(params: SignTransactionInput): Promise<_shared_clients_developer_controlled_wallets.SignTransactionResponseData>; /** Route to `createTransaction` (transfer) or `createContractExecutionTransaction` (when `data` set); wait for `SENT`. */ protected circle_sendTransaction(params: RpcTransactionRequest & { from: Hex; to: Hex; }): Promise<_shared_clients_developer_controlled_wallets.Transaction>; /** * Fetch the `defaultFeeLevel` tier with the configured buffer applied. * * Contract-execution estimates are sender-aware (`sourceAddress` behaves * like `msg.sender`); transfer estimates are sender-agnostic. */ protected circle_estimateFee(params: RpcTransactionRequest): Promise; /** Translate EIP-1193 fee fields into `FeeConfiguration`. */ protected toCircleFeeConfiguration(params: RpcTransactionRequest): Promise; } /** Create an EIP-1193 provider — drives a DCW wallet via any EIP-1193 consumer. */ declare function createEIP1193Provider(options: ConstructorParameters[0]): Provider; /** JSON-RPC -32601 — routes to optional `fallback` when configured. */ declare class MethodNotFoundRpcError extends Error { name: string; code: number; constructor(cause: Error | undefined, { method }: { method: string; }); } /** Thrown when the requested chain is not supported. */ declare class UnsupportedChainError extends Error { } export { MethodNotFoundRpcError, Provider, SUPPORTED_CHAINS, UnsupportedChainError, createEIP1193Provider, resolveChain }; export type { Chain, ChainIdentifier, EIP1193Provider, Hex, NativeUnits, RpcTransactionRequest };