Stellar PHP SDK API Documentation

StrKey
in package

StrKey is a helper class that allows encoding and decoding Stellar keys to/from strings, i.e. between their binary and string (i.e. "GABCD...", etc.) representations.

Tags
see
https://developers.stellar.org

Stellar developer docs Address types documentation

Table of Contents

Methods

accountIdFromPrivateKey()  : string
Derives the account ID from a private key
accountIdFromSeed()  : string
Derives the account ID from a secret seed
decodeAccountId()  : string
Decodes strkey account id (ed25519 public key) to raw data.
decodeClaimableBalanceId()  : string
Decodes strkey claimable balance id (B...) to raw data.
decodeClaimableBalanceIdHex()  : string
Decodes strkey claimable balance id (B...) to hex representation of it`s raw data
decodeContractId()  : string
Decodes strkey contract id (C...) to raw data.
decodeContractIdHex()  : string
Decodes strkey contract id (C...) to hex representation of it`s raw data
decodeLiquidityPoolId()  : string
Decodes strkey liquidity pool id (L...) to raw data.
decodeLiquidityPoolIdHex()  : string
Decodes strkey liquidity pool id (L...) to hex representation of it`s raw data
decodeMuxedAccountId()  : string
Decodes strkey muxed account id (med25519 public key) to raw data.
decodePreAuthTx()  : string
Decodes strkey PreAuthTx ("T...") to raw data.
decodeSeed()  : string
Decodes strkey ed25519 seed ("S...") to raw data.
decodeSha256Hash()  : string
Decodes strkey sha256 hash ("X...") to raw data.
decodeSignedPayload()  : SignedPayloadSigner
Decodes strkey signed payload ("P...") to a SignedPayloadSigner object.
decodeXdrSignedPayload()  : XdrSignedPayload
Decodes strkey signed payload ("P...") to a XdrSignedPayload object.
encodeAccountId()  : string
Encodes `data` to strkey account id (ed25519 public key).
encodeClaimableBalanceId()  : string
Encodes raw data to strkey claimable balance id (B...).
encodeClaimableBalanceIdHex()  : string
Encodes hex representation of raw data claimable balance id to strkey claimable balance id (B...).
encodeContractId()  : string
Encodes raw data to strkey contract id (C...).
encodeContractIdHex()  : string
Encodes hex representation of raw data contract id to strkey contract id (C...).
encodeLiquidityPoolId()  : string
Encodes raw data to strkey liquidity pool id (L...).
encodeLiquidityPoolIdHex()  : string
Encodes hex representation of raw data liquidity pool id to strkey liquidity pool id (L...).
encodeMuxedAccountId()  : string
Encodes data to strkey muxed account id (med25519 public key).
encodePreAuthTx()  : string
Encodes data to strkey PreAuthTx ("T...").
encodeSeed()  : string
Encodes data to strkey ed25519 seed ("S...")
encodeSha256Hash()  : string
Encodes data to strkey sha256 hash ("X...").
encodeSignedPayload()  : string
Encodes a SignedPayloadSigner to strkey signed payload (P...).
encodeXdrSignedPayload()  : string
Encodes a XdrSignedPayload to strkey signed payload (P...).
isValidAccountId()  : bool
Returns true if the given Stellar account id ("G...") is a valid ed25519 public key.
isValidClaimableBalanceId()  : bool
Returns true if the given strkey representation of the claimable balance id ("B...") is a valid claimable balance id.
isValidContractId()  : bool
Returns true if the given strkey representation of the contract id ("C...") is a valid contract id.
isValidLiquidityPoolId()  : bool
Returns true if the given strkey representation of the liquidity pool id ("L...") is a valid liquidity pool id.
isValidMuxedAccountId()  : bool
Returns true if the given Stellar muxed account id ("M...") is a valid med25519 public key.
isValidPreAuthTx()  : bool
Returns true if the given strkey PreAuthTx ("T...") is a valid stellar PreAuthTx strkey representation.
isValidSeed()  : bool
Returns true if the given Stellar secret key ("S...") is a valid ed25519 secret seed.
isValidSha256Hash()  : bool
Returns true if the given strkey Sha256Hash ("X...") is a valid stellar Sha256Hash strkey representation.
publicKeyFromPrivateKey()  : string
Derives the public key from a private key

Methods

accountIdFromPrivateKey()

Derives the account ID from a private key

public static accountIdFromPrivateKey(string $privateKey) : string
Parameters
$privateKey : string

The Ed25519 private key (32 bytes)

Return values
string

The account ID in strkey format (G...)

accountIdFromSeed()

Derives the account ID from a secret seed

public static accountIdFromSeed(string $seed) : string
Parameters
$seed : string

The secret seed in strkey format (S...)

Return values
string

The account ID in strkey format (G...)

decodeAccountId()

Decodes strkey account id (ed25519 public key) to raw data.

public static decodeAccountId(string $accountId) : string
Parameters
$accountId : string

"G..." key representation to decode

Return values
string

raw key

decodeClaimableBalanceId()

Decodes strkey claimable balance id (B...) to raw data.

public static decodeClaimableBalanceId(string $claimableBalanceId) : string
Parameters
$claimableBalanceId : string

claimable balance id (B...) to decode

Return values
string

raw data

decodeClaimableBalanceIdHex()

Decodes strkey claimable balance id (B...) to hex representation of it`s raw data

public static decodeClaimableBalanceIdHex(string $claimableBalanceId) : string
Parameters
$claimableBalanceId : string

strkey claimable balance id (B...) to decode

Return values
string

hex representation of the claimable balance id's raw data

decodeContractId()

Decodes strkey contract id (C...) to raw data.

public static decodeContractId(string $contractId) : string
Parameters
$contractId : string

strkey contract id (C...) to decode

Return values
string

raw data

decodeContractIdHex()

Decodes strkey contract id (C...) to hex representation of it`s raw data

public static decodeContractIdHex(string $contractId) : string
Parameters
$contractId : string

strkey contract id (C...) to decode

Return values
string

hex representation of the contract id's raw data

decodeLiquidityPoolId()

Decodes strkey liquidity pool id (L...) to raw data.

public static decodeLiquidityPoolId(string $liquidityPoolId) : string
Parameters
$liquidityPoolId : string

liquidity pool id (L...) to decode

Return values
string

raw data

decodeLiquidityPoolIdHex()

Decodes strkey liquidity pool id (L...) to hex representation of it`s raw data

public static decodeLiquidityPoolIdHex(string $liquidityPoolId) : string
Parameters
$liquidityPoolId : string

strkey liquidity pool id (L...) to decode

Return values
string

hex representation of the liquidity pool id's raw data

decodeMuxedAccountId()

Decodes strkey muxed account id (med25519 public key) to raw data.

public static decodeMuxedAccountId(string $muxedAccountId) : string
Parameters
$muxedAccountId : string

address data to decode ("M...")

Return values
string

raw key

decodePreAuthTx()

Decodes strkey PreAuthTx ("T...") to raw data.

public static decodePreAuthTx(string $preAuth) : string
Parameters
$preAuth : string

PreAuthTx ("T...") to decode

Return values
string

raw PreAuthTx data

decodeSeed()

Decodes strkey ed25519 seed ("S...") to raw data.

public static decodeSeed(string $seed) : string
Parameters
$seed : string

seed ("S...") to decode

Return values
string

raw seed data

decodeSha256Hash()

Decodes strkey sha256 hash ("X...") to raw data.

public static decodeSha256Hash(string $hash) : string
Parameters
$hash : string

strkey sha256 hash ("X...") to decode

Return values
string

raw sha256 hash data.

decodeSignedPayload()

Decodes strkey signed payload ("P...") to a SignedPayloadSigner object.

public static decodeSignedPayload(string $signedPayload) : SignedPayloadSigner
Parameters
$signedPayload : string

signed payload ("P...") to decode

Return values
SignedPayloadSigner

object decoded from the given strkey signed payload

decodeXdrSignedPayload()

Decodes strkey signed payload ("P...") to a XdrSignedPayload object.

public static decodeXdrSignedPayload(string $signedPayload) : XdrSignedPayload
Parameters
$signedPayload : string

signed payload ("P...") to decode

Return values
XdrSignedPayload

object decoded from the given strkey signed payload

encodeAccountId()

Encodes `data` to strkey account id (ed25519 public key).

public static encodeAccountId(string $data) : string
Parameters
$data : string

raw data to encode

Return values
string

"G..." representation of the key

encodeClaimableBalanceId()

Encodes raw data to strkey claimable balance id (B...).

public static encodeClaimableBalanceId(string $data) : string
Parameters
$data : string

raw data to encode

Return values
string

strkey claimable balance id (B...).

encodeClaimableBalanceIdHex()

Encodes hex representation of raw data claimable balance id to strkey claimable balance id (B...).

public static encodeClaimableBalanceIdHex(string $claimableBalanceId) : string
Parameters
$claimableBalanceId : string

hex representation of raw data claimable balance id

Return values
string

strkey representation of the claimable balance id (B...).

encodeContractId()

Encodes raw data to strkey contract id (C...).

public static encodeContractId(string $data) : string
Parameters
$data : string

data to encode

Return values
string

strkey contract id (C...).

encodeContractIdHex()

Encodes hex representation of raw data contract id to strkey contract id (C...).

public static encodeContractIdHex(string $contractId) : string
Parameters
$contractId : string

hex representation of raw data contract id

Return values
string

strkey representation of the contract id (C...).

encodeLiquidityPoolId()

Encodes raw data to strkey liquidity pool id (L...).

public static encodeLiquidityPoolId(string $data) : string
Parameters
$data : string

raw data to encode

Return values
string

strkey liquidity pool id (L...).

encodeLiquidityPoolIdHex()

Encodes hex representation of raw data liquidity pool id to strkey liquidity pool id (L...).

public static encodeLiquidityPoolIdHex(string $liquidityPoolId) : string
Parameters
$liquidityPoolId : string

hex representation of raw data liquidity pool id

Return values
string

strkey representation of the liquidity pool id (L...).

encodeMuxedAccountId()

Encodes data to strkey muxed account id (med25519 public key).

public static encodeMuxedAccountId(string $data) : string
Parameters
$data : string

data data to encode

Return values
string

"M..." representation of the key

encodePreAuthTx()

Encodes data to strkey PreAuthTx ("T...").

public static encodePreAuthTx(string $data) : string
Parameters
$data : string

data to encode

Return values
string

"T..." representation of the PreAuthTx

encodeSeed()

Encodes data to strkey ed25519 seed ("S...")

public static encodeSeed(string $data) : string
Parameters
$data : string

data to encode

Return values
string

"S..." representation of the seed

encodeSha256Hash()

Encodes data to strkey sha256 hash ("X...").

public static encodeSha256Hash(string $data) : string
Parameters
$data : string

data to encode

Return values
string

"X..." representation of the sha256 hash

encodeSignedPayload()

Encodes a SignedPayloadSigner to strkey signed payload (P...).

public static encodeSignedPayload(SignedPayloadSigner $signedPayloadSigner) : string
Parameters
$signedPayloadSigner : SignedPayloadSigner

SignedPayloadSigner to encode

Return values
string

"P..." representation of the signed payload

encodeXdrSignedPayload()

Encodes a XdrSignedPayload to strkey signed payload (P...).

public static encodeXdrSignedPayload(XdrSignedPayload $signedPayload) : string
Parameters
$signedPayload : XdrSignedPayload

XdrSignedPayload to encode

Return values
string

"P..." representation of the signed payload

isValidAccountId()

Returns true if the given Stellar account id ("G...") is a valid ed25519 public key.

public static isValidAccountId(string $accountId) : bool
Parameters
$accountId : string

account id ("G...") to check

Return values
bool

true if valid

isValidClaimableBalanceId()

Returns true if the given strkey representation of the claimable balance id ("B...") is a valid claimable balance id.

public static isValidClaimableBalanceId(string $claimableBalanceId) : bool
Parameters
$claimableBalanceId : string

the claimable balance id ("B...") to check.

Return values
bool

true if valid

isValidContractId()

Returns true if the given strkey representation of the contract id ("C...") is a valid contract id.

public static isValidContractId(string $contractId) : bool
Parameters
$contractId : string

contract id ("C...") to check

Return values
bool

true if valid contract id strkey representation.

isValidLiquidityPoolId()

Returns true if the given strkey representation of the liquidity pool id ("L...") is a valid liquidity pool id.

public static isValidLiquidityPoolId(string $liquidityPoolId) : bool
Parameters
$liquidityPoolId : string

the liquidity pool id ("L...") to check.

Return values
bool

true if valid

isValidMuxedAccountId()

Returns true if the given Stellar muxed account id ("M...") is a valid med25519 public key.

public static isValidMuxedAccountId(string $muxedAccountId) : bool
Parameters
$muxedAccountId : string

muxed account id ("M...") to check

Return values
bool

true if valid

isValidPreAuthTx()

Returns true if the given strkey PreAuthTx ("T...") is a valid stellar PreAuthTx strkey representation.

public static isValidPreAuthTx(string $preAuth) : bool
Parameters
$preAuth : string

strkey PreAuthTx ("T...") to check

Return values
bool

true if valid stellar PreAuthTx strkey representation.

isValidSeed()

Returns true if the given Stellar secret key ("S...") is a valid ed25519 secret seed.

public static isValidSeed(string $seed) : bool
Parameters
$seed : string

seed to check ("S...")

Return values
bool

true if valid

isValidSha256Hash()

Returns true if the given strkey Sha256Hash ("X...") is a valid stellar Sha256Hash strkey representation.

public static isValidSha256Hash(string $hash) : bool
Parameters
$hash : string

strkey Sha256Hash ("X...") to ckeck

Return values
bool

true if valid stellar Sha256Hash strkey representation.

publicKeyFromPrivateKey()

Derives the public key from a private key

public static publicKeyFromPrivateKey(string $privateKey) : string
Parameters
$privateKey : string

The Ed25519 private key (32 bytes)

Tags
throws
Exception

If the private key is invalid or key derivation fails

Return values
string

The corresponding Ed25519 public key (32 bytes)


        
On this page

Search results