NEARFeeContract
SIP Protocol API Reference v0.12.0
SIP Protocol API Reference / NEARFeeContract
Class: NEARFeeContract
Section titled “Class: NEARFeeContract”Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24876
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-rqQpCeVM.d.ts:24883
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-rqQpCeVM.d.ts:24887
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-rqQpCeVM.d.ts:24891
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-rqQpCeVM.d.ts:24902
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-rqQpCeVM.d.ts:24906
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-rqQpCeVM.d.ts:24910
Get contract state
Returns
Section titled “Returns”Promise<FeeContractState>
getConfig()
Section titled “getConfig()”getConfig():
Promise<ChainFeeConfig>
Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24914
Get fee configuration
Returns
Section titled “Returns”Promise<ChainFeeConfig>
updateConfig()
Section titled “updateConfig()”updateConfig(
config):Promise<void>
Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24918
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-rqQpCeVM.d.ts:24922
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-rqQpCeVM.d.ts:24926
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-rqQpCeVM.d.ts:24930
Pause fee collection (emergency)
Returns
Section titled “Returns”Promise<void>
resume()
Section titled “resume()”resume():
Promise<void>
Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24934
Resume fee collection
Returns
Section titled “Returns”Promise<void>
isPaused()
Section titled “isPaused()”isPaused():
Promise<boolean>
Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24938
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-rqQpCeVM.d.ts:24944
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-rqQpCeVM.d.ts:24948
Get contract ID
Returns
Section titled “Returns”string
getNetwork()
Section titled “getNetwork()”getNetwork():
"testnet"|"mainnet"
Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24952
Get network
Returns
Section titled “Returns”"testnet" | "mainnet"
getRpcUrl()
Section titled “getRpcUrl()”getRpcUrl():
string
Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24956
Get RPC URL
Returns
Section titled “Returns”string