Skip to main content

Introduction

Before using the Züs JS SDK, you need to initialize the SDK first. See Quick Start guide for more details.

After initializing the SDK, you can use the Züs JS SDK to perform various operations such as creating and managing allocations, uploading and downloading files, executing smart contracts, and more.

SDK Methods Index

In this guide, we will introduce you to all the available methods provided by the Züs JS SDK.

Wallet Methods

The wallet methods allow you to create and manage wallets, set the wallet, and get wallet information.

MethodDescription
createWalletCreate a new wallet. Also, helps to recover a wallet using its mnemonic phrase.
createWalletKeysCreate a new wallet keys and mnemonic.
getPublicEncryptionKeyGet the public encryption key by wallet mnemonic.
isWalletIdCheck whether thef wallet id is valid.
sendSend token from one wallet to another.
getWalletBalanceGet the balance of a wallet.
getUSDRateGet the USD rate by token symbol. (e.g. zcn, eth)

Burn & Mint Methods

The initBridge method must be called to initialize the bridge client before using the any of the burn and mint methods.

MethodDescription
initBridgeInitialize the bridge for calling burn and mint functions.
burnZCNBridge method to burn ZCN tokens.
mintZCNBridge method to mint ZCN tokens.
getMintWZCNPayloadBridge method to get Mint WZCN Payload for a given burn transaction hash.
getUnprocessedWZCNBurnEventsGet all unprocessed WZCN burn events from the Ethereum network.
getProcessedZCNBurnTicketsGet all processed ZCN burn tickets burned for a certain Ethereum address.
estimateMintWZCNGasAmountPerform gas amount estimation for the given Mint WZCN transaction.
estimateBurnWZCNGasAmountPerform gas amount estimation for the given burn WZCN transaction.
estimateGasPricePerform gas estimation for the given transaction using Alchemy enhanced API returning approximate final gas fee.

Allocation Storage Methods

The allocation storage methods allow you to create, update, and manage allocations.

MethodDescription
createAllocationCreates an allocation with the specified allocation terms and preferred blobber IDs.
getAllocationMinLockRetrieves the minimum lock value for the allocation creation.
listAllocationsList all the allocations.
getAllocationGets allocation details for a given allocationId from cache or the blockchain.
reloadAllocationRe-fetches allocation details using allocationId from blockchain and updates cache.
getAllocationWithGet allocation details of a free allocation or a shared allocation details by using an authTicket.
freezeAllocationFreeze an allocation so that the allocation data can no longer be modified.
cancelAllocationCancel an Allocation
updateAllocationUpdate the allocation settings
updateAllocationWithRepairUpdates your allocation settings and repairs the allocation if any blobber was replaced or added
getUpdateAllocationMinLockRetrieves the minimum lock value for the allocation after update.
updateForbidAllocationUpdateForbidAllocation updates the permissions of an allocation, given the permission parameters in a forbid-first manner.
getUpdateAllocTicketGenerates and signs an "Update Allocation ticket", which authorizes the "add blobber" or "replace blobber" operation from other wallets.
checkAllocStatusCheck the health status of the allocation.
skipStatusCheckSkips the checkAlloctionStatus health status check of the allocation.
repairAllocationStart a repair process for an allocation.
repairSizeRetrieves the repair size for a specific path in an allocation.
createWorkersManually create local workers that sync with the allocation.
terminateWorkersRemove local workers that sync with the allocation. This is useful when switching between allocations.

Blobber Methods

The blobber methods allow you to retrieve information, manage and interact with blobbers.

MethodDescription
getBlobbersRetrieves a list of active blobbers details from the network
getBlobberIdsGet Blobber IDs from a list of blobber URLs
getAllocationBlobbersRetrieves a list of blobber IDs of blobber which match your allocation terms
updateBlobberSettingsUpdates the blobber settings
getContainersGetContainers returns all the running containers in a given domain.
searchContainersearchContainer searches for a container with a given name in a given domain.
updateContainerUpdateContainer updates the given container ID with a new image ID in a given domain.

File Operation Methods

The file operation methods allow you to perform various operations on files.

MethodDescription
getLookupHashGenerate lookup hash for a given file path and allocation ID
createDirCreate a folder on the blobbers
setUploadModeSets the upload mode for modifying the upload speed and CPU usage
multiUploadUpload multiple files in a batch. Also, used to resume a paused upload.
pauseUploadPause the upload operation of the file.
cancelUploadCancel the upload operation of the file.
getFileStatsGets the file stats
listObjectsList the files for a given allocation ID and remote path
getFileMetaByNameGet file metadata by name. (File Search)
multiDownloadDownload multiple files together
downloadBlocksDownloads a specified range of blocks from a file.
cancelDownloadBlocksCancels the download of a specified range of blocks from a file.
downloadDirectoryDownload files in a directory.
cancelDownloadDirectoryCancel the download of a directory.
multiOperationPerform multiple file operations (copy, move, delete, create directory) together
deleteFileDeletes a file from an allocation. Only the owner of the allocation can delete a file. Prefer multiOperation for deleting multiple files.
shareGenerate an authToken that provides the authorization to the holder to the specified file on the remotepath.
listObjectsFromAuthTicketList objects from an auth ticket. It's useful for accessing a shared resource by a non-owner

Smart Contract Methods

The smart contract methods allow you to interact with smart contracts.

MethodDescription
makeSCRestAPICallIssues a request to the public API of the smart contracts
getStakePoolInfoGet information about the stake pool for the allocation
lockWritePoolLock given number of tokens for given duration in write pool
lockStakePoolStake number of tokens for a given provider given its type and ID
unlockStakePoolUnlock the write pool
collectRewardsCollect all rewards for a given delegate and provider pair.

Utility Functions

MethodDescription
decodeAuthTicketDecode the AuthTicket of a shared file
getGosdkVersionRetrieves the version of the initialized GoSDK WASM.
getWasmTypeReturns the type of the GoSDK WASM file (standard or enterprise).
sasTokenToZcnConverts SAS token value in ZCN
zcnToSasTokenConverts ZCN value in SAS token
checkIfWasmLoadedWaits until the "desired mode" GoSDK WASM is loaded and initialized.
awaitWasmLoadWaits until the GoSDK WASM is loaded and initialized.
updateWasmModeUpdates the "desired mode" value of the GoSDK WASM.
getDesiredModeReturns the "desired mode" value of the GoSDK WASM.
isDesiredWasmInitializedChecks if the desired GoSDK WASM mode is initialized. Returns true if the WASM is initialized, false otherwise.