zkLink X Documentaion
HomeGitHubBlogExplorer
  • 🙂Welcome
    • Introduction
  • ⚖️Architecture
    • Overview
    • Settlement Layer
      • Working Principal of A Multi-Chain ZK-Rollup
      • Nexus: Settlement on ETH L2s
      • Origin: Settlement on ETH and Alt-L1s
      • Multi-Chain State Synchronization
        • In-Detail: Nexus Multi-Chain State Synchronization
      • Supported Networks of zkLink Nexus and Origin
      • Security Assumptions of zkLink Nexus and Origin
    • Execution Layer
      • TS-zkVM for App Rollup
    • Sequencing Layer
    • DA Layer
  • 🛠️Developer
    • Developer Overview
    • Get Started
    • Examples
      • Base Demo
    • JSON RPC & Websocket & Kafka
      • JSON-RPC API
      • JSON-RPC Errors
      • Websocket
      • Kafka
    • Transactions
      • Basic Types
      • State Update
      • Transaction
        • Deposit
        • FullExit
        • ChangePubKey
        • Withdraw
        • Transfer
        • ForcedExit
        • OrderMatching
        • AutoDeleveraging
        • ContractMatching
        • Funding
        • Liquidation
        • UpdateGlobalVar
      • Private Key & Signature
        • Algorithm
        • ChangePubKey
        • Withdraw
        • Transfer
        • ForcedExit
        • OrderMatching
        • ContractMatching
        • Funding
        • Liquidation
        • AutoDeleveraging
        • UpdateGlobalVar
    • SDK
      • Go
        • Types
        • Signature
        • Utils
        • Transactions
          • ChangePubKey
          • Withdraw
          • Transfer
          • ForcedExit
          • OrderMatching
          • ContractMatching
          • AutoDeleveraging
          • Funding
          • Liquidation
          • UpdateGlobalVar
      • Js
        • Signature
        • Utils
        • Transactions
          • ChangePubKey
          • Withdraw
          • Transfer
          • ForcedExit
          • OrderMatching
          • ContractMatching
          • AutoDeleveraging
          • Funding
          • Liquidation
          • UpdateGlobalVar
      • Dart
        • Signature
        • Utils
        • Transactions
          • ChangePubKey
          • Withdraw
          • Transfer
          • ForcedExit
          • OrderMatching
          • ContractMatching
          • AutoDeleveraging
          • Funding
          • Liquidation
          • UpdateGlobalVar
  • ⚙️Network Information
    • Connected Networks
      • Mainnet
      • Testnet
    • DApps & Deployment Addresses
      • Mainnet
      • Testnet
  • Wallet & User Fund Streamline
    • Withdraw
    • Wallet Integration & AA Wallet
    • Deposit
  • Integration Cases
    • Heavyweight Integration (Multi-Chain Derivatives & Spot Exchange)
    • Simple Integration (Multi-Chain Spot Exchange)
  • Appendix
    • Audits
    • FAQ
    • glossary
Powered by GitBook
On this page

Was this helpful?

  1. Developer
  2. SDK
  3. Js

Utils

func isTokenAmountPackable

/**
* @param {string} amount
* @returns {boolean}
*/
isTokenAmountPackable(amount: string)

Checks whether the token amount can be packed (and thus used in the transaction)

func isFeeAmountPackable

/**
* @param {string} fee
* @returns {boolean}
*/
isFeeAmountPackable(fee: string)

Checks whether the fee amount can be packed (and thus used in the transaction)

func closestPackableTransactionAmount

/**
* @param {string} amount
* @returns {string}
*/
closestPackableTransactionAmount(amount: string)

Returns the closest possible packable token amount. Returned amount is always less or equal to the provided amount.

func closestPackableTransactionFee

/**
* @param {string} fee
* @returns {string}
*/
closestPackableTransactionFee(fee: string)

Returns the closest possible packable fee amount. Returned amount is always less or equal to the provided amount.

Example

let amount = "1234567899808787";
console.log("Original amount: " + amount);
console.assert(isTokenAmountPackable(amount) == false);
amount = wasm.closestPackableTransactionAmount(amount);
console.assert(isTokenAmountPackable(amount));
console.log("Converted amount: " + amount);
let fee = "10000567777";
console.log("Original fee: " + fee);
console.assert(isFeeAmountPackable(fee) == false);
fee = wasm.closestPackableTransactionFee(fee)
console.assert(isFeeAmountPackable(fee));
console.log("Converted fee: " + fee);
PreviousSignatureNextTransactions

Last updated 11 months ago

Was this helpful?

🛠️