SecretSDK interface

Hierarchy

  • SecretSDK

Constructors

  • Parameters

    • account: SecretAccount
    • serverAddr: string
    • circuitPath: string
    • eddsa: any
    • userAccount: any
    • spongePoseidonAddress: string
    • tokenRegistryAddress: string
    • poseidon2Address: string
    • poseidon3Address: string
    • poseidon6Address: string
    • rollupAddress: string
    • smtVerifierAddress: string = ""

    Returns SecretSDK

Properties

account: SecretAccount
alias: string
circuitPath: string
eddsa: any
noteBuff: any[] = ...
rollupSC: RollupSC
serverAddr: any
txBuff: any[] = ...

Methods

  • Parameters

    • encryptedNotes: any

    Returns Promise<void>

  • Parameters

    • ctx: Context
    • notes: Note[]
    • encryptedNotes: any[]

    Returns Promise<AppResp>

  • Parameters

    • token: string
    • value: bigint

    Returns Promise<any>

  • register testToken to rollup contract

    Parameters

    • token: string

    Returns Promise<any>

  • Create proof for the secret account created.

    Returns

    An AppResp object with data property of type 'string[]' which contains a batch of proof for the createAccount.

    Parameters

    • ctx: Context
    • password: string

      The password used to decrypt the SecretAccount.

    Returns Promise<AppResp>

  • Parameters

    • ctx: Context
    • token: string
    • assetId: any

    Returns Promise<AppResp>

  • Parameters

    • ctx: Context
    • password: string

    Returns Promise<AppResp>

  • Parameters

    • txData: string
    • proofAndPublicSignals: any
    • operation: string

    Returns Promise<void>

  • Parameters

    • resource: string
    • params: any

    Returns Promise<AppResp>

  • Create proof for the deposit of the asset from L1 to L2.

    Returns

    An AppResp object with data property of type 'string[]' which contains a batch of proof for the deposit.

    Parameters

    • ctx: Context
    • receiver: string

      The receiver account address for the deposit.

    • value: bigint

      The amount of asset to be deposited.

    • assetId: number

      The token to be deposited.

    • nonce: number

      The nonce of the current transaction, usually obtained from a wallet like Metamask.

    Returns Promise<AppResp>

  • Parameters

    • _ctx: Context

    Returns Promise<void>

  • Parameters

    • ctx: Context
    • options: any

    Returns Promise<AppResp>

  • Parameters

    • _ctx: Context
    • value: string | bigint
    • assetId: number
    • decimals: number = 18

    Returns string

  • Retrieve all current user's unspent notes.

    Returns

    An AppResp object with data property of type Array<Note> if notes are successfully retrieved.

    Parameters

    • ctx: Context
    • noteState: NoteState[]
    • indices: string[] = []
    • skipZeroNote: boolean = true

      is false if all notes(with val 0) are required to return

    Returns Promise<AppResp>

  • Fetch registered token list from server

    Returns

    token symbol to token asset id and it's contract address, e.g. { message: 'Success', errno: 0, data: [ { assetId: '2', latest_price: 1, latest_24h_price: 1, tokenInfo: { chainId: '', address: '0x0165878A594ca255338adfa4d48449f69242Eb8F', name: 'Unknown Token', symbol: '', decimals: 18, logoURI: '', extensions: '' } } ] }

    Parameters

    • ctx: Context

    Returns Promise<AppResp>

  • Parameters

    • id: number

    Returns Promise<any>

  • Returns

    transactions, e.g. [ { operation: 'deposit', amount: '0', assetId: 2, to: '', txhash: '', timestamp: '2023-05-14 13:52:12.546 +00:00' } ]

    Parameters

    • ctx: Context
    • options: any

    Returns Promise<AppResp>

  • Connect the rollup contracts.

    Parameters

    • contractABI: any

      the contracts ABI directory

    Returns Promise<void>

  • Create proof for migrating the account to another ETH address.

    Returns

    An AppResp object with data property of type 'string[]' which contains a batch of proof for the migrateAccount.

    Parameters

    • ctx: Context
    • newAccountKey: SigningKey

      The account key that which user renews.

    • password: string

      The password used to decrypt the SecretAccount.

    Returns Promise<AppResp>

  • Parameters

    • _ctx: Context
    • value: string
    • assetId: number
    • decimals: number = 18

    Returns bigint

  • register testToken to rollup contract

    Parameters

    • token: string

    Returns Promise<void>

  • Creates proof for sending an asset from the sender to the receiver in L2.

    Returns

    An AppResp object with data property of type 'string[]' which contains a batch of proof for the send.

    Parameters

    • ctx: Context
    • receiver: string

      The receiver account address for the send.

    • receiverAlias: string

      The receiver's alias or ‘__DEFAULT_ALIAS__’.

    • value: bigint

      The amount of asset to be sent.

    • assetId: number

      The token to be sent.

    Returns Promise<AppResp>

  • register testToken to rollup contract

    Returns Promise<void>

  • Parameters

    • ctx: Context
    • proofs: any

    Returns Promise<AppResp>

  • Create a proof for updating the user's signing key.

    Returns

    An AppResp object with data property of type 'string[]' which contains a batch of proof for the updateAccount.

    Parameters

    • ctx: Context
    • newSigningKey: SigningKey

      The new signing key to be updated to.

    • password: string

      The password used to decrypt the SecretAccount.

    Returns Promise<any>

  • Parameters

    • ctx: Context
    • password: string

    Returns Promise<AppResp>

  • Parameters

    • ctx: Context
    • outputNc1: bigint
    • nullifier1: bigint
    • outputNc2: bigint
    • nullifier2: bigint
    • acStateKey: bigint
    • padding: boolean = true

    Returns Promise<AppResp>

  • Creates a proof for withdrawing an asset from L2 to L1.

    Returns

    An AppResp object with data property of type 'string[]' which contains a batch of proof for the withdraw.

    Parameters

    • ctx: Context
    • receiver: string
    • value: bigint

      The amount to be withdrawn.

    • assetId: number

      The token to be withdrawn.

    Returns Promise<AppResp>

  • Parameters

    • serverAddr: string
    • resource: string
    • params: any

    Returns Promise<AppResp>

  • Initializes the SDK from either an existing account or no account.

    Returns

    An AppResp object with data property of type 'class' that contains the initialized SecretSDK instance.

    Parameters

    • ctx: Context
    • serverAddr: string

      The address of the server to connect to.

    • password: string

      The password used to encrypt the SecretAccount for secure storage.

    • user: any

      The Ethereum address of the user.

    • contractJson: any

      The JSON object for the contract.

    • circuitPath: string

      The path to the circuit file.

    • contractABI: any

      The ABI of the contract.

    • Optional isCreate: boolean = false

      the flag indicating whether to create a new account. Optional.

    Returns Promise<AppResp>

Generated using TypeDoc