NEARFeeContract
SIP Protocol API Reference v0.7.4
SIP Protocol API Reference / NEARFeeContract
Class: NEARFeeContract
Section titled “Class: NEARFeeContract”Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24576
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-DXh2IGkz.d.ts:24583
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-DXh2IGkz.d.ts:24587
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-DXh2IGkz.d.ts:24591
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-DXh2IGkz.d.ts:24602
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-DXh2IGkz.d.ts:24606
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-DXh2IGkz.d.ts:24610
Get contract state
Returns
Section titled “Returns”Promise<FeeContractState>
getConfig()
Section titled “getConfig()”getConfig():
Promise<ChainFeeConfig>
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24614
Get fee configuration
Returns
Section titled “Returns”Promise<ChainFeeConfig>
updateConfig()
Section titled “updateConfig()”updateConfig(
config):Promise<void>
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24618
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-DXh2IGkz.d.ts:24622
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-DXh2IGkz.d.ts:24626
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-DXh2IGkz.d.ts:24630
Pause fee collection (emergency)
Returns
Section titled “Returns”Promise<void>
resume()
Section titled “resume()”resume():
Promise<void>
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24634
Resume fee collection
Returns
Section titled “Returns”Promise<void>
isPaused()
Section titled “isPaused()”isPaused():
Promise<boolean>
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24638
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-DXh2IGkz.d.ts:24644
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-DXh2IGkz.d.ts:24648
Get contract ID
Returns
Section titled “Returns”string
getNetwork()
Section titled “getNetwork()”getNetwork():
"testnet"|"mainnet"
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24652
Get network
Returns
Section titled “Returns”"testnet" | "mainnet"
getRpcUrl()
Section titled “getRpcUrl()”getRpcUrl():
string
Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24656
Get RPC URL
Returns
Section titled “Returns”string