NEARFeeContract
SIP Protocol API Reference v0.15.1
SIP Protocol API Reference / NEARFeeContract
Class: NEARFeeContract
Section titled “Class: NEARFeeContract”Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24912
NEAR Fee Contract Client
Provides interface for fee calculation and collection on NEAR.
Example
Section titled “Example”const feeContract = new NEARFeeContract({ network: 'mainnet',})
// Calculate feeconst fee = await feeContract.calculateFee({ amount: 1000000000000000000000000n, // 1 NEAR amountUsd: 5.00, sourceChain: 'near', destinationChain: 'ethereum',})
console.log(`Fee: ${fee.protocolFeeUsd} USD`)Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new NEARFeeContract(
options?):NEARFeeContract
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24919
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”NEARFeeContract
Methods
Section titled “Methods”calculateFee()
Section titled “calculateFee()”calculateFee(
params):Promise<FeeCalculationResult>
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24923
Calculate fee for a transaction
Parameters
Section titled “Parameters”params
Section titled “params”Returns
Section titled “Returns”Promise<FeeCalculationResult>
estimateFee()
Section titled “estimateFee()”estimateFee(
amountUsd,sourceChain?):Promise<{feeUsd:number;bps:number;tierName?:string; }>
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24927
Get fee estimate for UI display
Parameters
Section titled “Parameters”amountUsd
Section titled “amountUsd”number
sourceChain?
Section titled “sourceChain?”Returns
Section titled “Returns”Promise<{ feeUsd: number; bps: number; tierName?: string; }>
collectFee()
Section titled “collectFee()”collectFee(
params):Promise<FeeCollectionResult>
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24938
Collect fee for a transaction
In production, this would create a NEAR transaction to transfer the fee to the treasury. For now, it simulates the collection.
Parameters
Section titled “Parameters”params
Section titled “params”Returns
Section titled “Returns”Promise<FeeCollectionResult>
batchCollectFees()
Section titled “batchCollectFees()”batchCollectFees(
params):Promise<FeeCollectionResult[]>
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24942
Batch collect fees for multiple transactions
Parameters
Section titled “Parameters”params
Section titled “params”Returns
Section titled “Returns”Promise<FeeCollectionResult[]>
getState()
Section titled “getState()”getState():
Promise<FeeContractState>
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24946
Get contract state
Returns
Section titled “Returns”Promise<FeeContractState>
getConfig()
Section titled “getConfig()”getConfig():
Promise<ChainFeeConfig>
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24950
Get fee configuration
Returns
Section titled “Returns”Promise<ChainFeeConfig>
updateConfig()
Section titled “updateConfig()”updateConfig(
config):Promise<void>
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24954
Update fee configuration (owner only)
Parameters
Section titled “Parameters”config
Section titled “config”Partial<ChainFeeConfig>
Returns
Section titled “Returns”Promise<void>
getTreasury()
Section titled “getTreasury()”getTreasury():
Promise<FeeTreasuryConfig>
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24958
Get treasury configuration
Returns
Section titled “Returns”Promise<FeeTreasuryConfig>
getStats()
Section titled “getStats()”getStats(
startTime?,endTime?):Promise<FeeStats>
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24962
Get fee statistics
Parameters
Section titled “Parameters”startTime?
Section titled “startTime?”number
endTime?
Section titled “endTime?”number
Returns
Section titled “Returns”Promise<FeeStats>
pause()
Section titled “pause()”pause():
Promise<void>
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24966
Pause fee collection (emergency)
Returns
Section titled “Returns”Promise<void>
resume()
Section titled “resume()”resume():
Promise<void>
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24970
Resume fee collection
Returns
Section titled “Returns”Promise<void>
isPaused()
Section titled “isPaused()”isPaused():
Promise<boolean>
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24974
Check if fee collection is paused
Returns
Section titled “Returns”Promise<boolean>
withdrawToTreasury()
Section titled “withdrawToTreasury()”withdrawToTreasury(
amount?):Promise<string>
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24980
Withdraw fees to treasury
In production, this would create a NEAR transaction.
Parameters
Section titled “Parameters”amount?
Section titled “amount?”bigint
Returns
Section titled “Returns”Promise<string>
getContractId()
Section titled “getContractId()”getContractId():
string
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24984
Get contract ID
Returns
Section titled “Returns”string
getNetwork()
Section titled “getNetwork()”getNetwork():
"testnet"|"mainnet"
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24988
Get network
Returns
Section titled “Returns”"testnet" | "mainnet"
getRpcUrl()
Section titled “getRpcUrl()”getRpcUrl():
string
Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24992
Get RPC URL
Returns
Section titled “Returns”string