supra-ts-sdk - v2.0.0
    Preparing search index...

    Class SupraAccount

    Class for creating and managing Supra account

    JSON.stringify output, and Node.js util.inspect and console.log output, of an instance contain the address and the public key only. Browser developer tools list non-enumerable properties when a logged object is expanded, so they can still show signingKey. SupraAccount.toPrivateKeyObject exports the private key.

    Index
    • Parameters

      • obj: SupraAccountObject

      Returns SupraAccount

    • Checks if the derivation path matches m/44'/637'/a'/c'/i', where a, c and i are decimal integers and every level is hardened.

      Parameters

      • path: string

      Returns boolean

    • Creates new account from a BIP-44 derivation path and a BIP-39 mnemonic.

      The path has the form m/44'/637'/a'/c'/i': purpose 44, coin type 637, then account a, change c and address index i, all hardened (e.g. m/44'/637'/0'/0'/0'). Keys are derived with SLIP-0010 for Ed25519. Detailed description: https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki

      The mnemonic is trimmed, runs of whitespace are collapsed to one space and words are lower-cased; the result is then validated against the BIP-39 English wordlist and checksum.

      Parameters

      • path: string

        Derivation path of the form m/44'/637'/a'/c'/i'.

      • mnemonics: string

        BIP-39 mnemonic phrase (English wordlist).

      Returns SupraAccount

      SupraAccount

      Error Invalid derivation path if path does not match the pattern.

      Error Invalid mnemonic if the normalised phrase fails BIP-39 wordlist or checksum validation.

    • This is the key by which Supra account is referenced. It is the 32-byte of the SHA-3 256 cryptographic hash of the public key(s) concatenated with a signature scheme identifier byte

      Returns HexString

      Address associated with the given account

    • This key enables account owners to rotate their private key(s) associated with the account without changing the address that hosts their account.

      Returns HexString

      Authentication key for the associated account

    • Takes source address and seeds and returns the resource account address

      Parameters

      • sourceAddress: MaybeHexString

        Address used to derive the resource account

      • seed: Uint8Array

        The seed bytes

      Returns HexString

      The resource account address

    • Takes creator address and collection name and returns the collection id hash. Collection id hash are generated as sha256 hash of (creator_address::collection_name)

      Parameters

      • creatorAddress: MaybeHexString

        Collection creator address

      • collectionName: string

        The collection name

      Returns HexString

      The collection id hash

    • This key is generated with Ed25519 scheme. Public key is used to check a signature of transaction, signed by given account

      Returns HexString

      The public key for the associated account

    • Signs specified buffer with account's private key

      Parameters

      • buffer: Uint8Array

        A buffer to sign

      Returns HexString

      A signature HexString

    • Signs specified hexString with account's private key

      Parameters

      • hexString: MaybeHexString

        A regular string or HexString to sign

      Returns HexString

      A signature HexString

    • Verifies the signature of the message with the public key of the account

      Parameters

      • message: MaybeHexString

        a signed message

      • signature: MaybeHexString

        the signature of the message

      Returns boolean

    • Derives account address, public key and private key

      Returns SupraAccountObject

      SupraAccountObject instance.

      {
      address: "0xe8012714cd17606cee7188a2a365eef3fe760be598750678c8c5954eb548a591",
      publicKeyHex: "0xf56d8524faf79fbc0f48c13aeed3b0ce5dd376b4db93b8130a107c0a5e04ba04",
      privateKeyHex: `0x009c9f7c992a06cfafe916f125d8adb7a395fca243e264a8e56a4b3e6accf940
      d2b11e9ece3049ce60e3c7b4a1c58aebfa9298e29a30a58a67f1998646135204`
      }
    • Returns the account's non-secret data. JSON.stringify calls this method.

      Returns SupraAccountPublicData

      The address and the public key of the account

    • Returns the representation used by Node.js util.inspect and console.log, containing the address and the public key of the account.

      Returns string

      The inspection string

    • Creates new account instance. Constructor allows passing in an address, to handle account key rotation, where auth_key != public_key

      Parameters

      • OptionalprivateKeyBytes: Uint8Array<ArrayBufferLike>

        Private key from which account key pair will be generated. If not specified, new key pair is going to be created.

      • Optionaladdress: MaybeHexString

        Account address (e.g. 0xe8012714cd17606cee7188a2a365eef3fe760be598750678c8c5954eb548a591). If not specified, a new one will be generated from public key

      Returns SupraAccount

    signingKey: SignKeyPair

    A private key and public key, associated with the given account. Defined as a non-enumerable own property, so it is excluded from Object.keys, object spread and JSON.stringify.