Skip to main content

modules

[# Masa SDK

  • v1.2.0-alpha.1](/docs/developers/sdk/) / Exports

# Masa SDK

  • v1.2.0-alpha.1

Table of contents

Classes

Interfaces

Type Aliases

Variables

Functions

Type Aliases

CreateCreditScoreResult

Ƭ CreateCreditScoreResult: BaseResult


CreateLinkResult

Ƭ CreateLinkResult: BaseResult & { passport?: string }


Environment

Ƭ Environment: { name: "local" | "dev" | "test" | "stage" | "production" ; wallet?: ethers.Signer | ethers.Wallet } & MasaArgs


EnvironmentName

Ƭ EnvironmentName: "dev" | "test" | "beta" | "production"


EstablishLinkResult

Ƭ EstablishLinkResult: BaseResult


Ƭ Link: Object

Type declaration

NameType
existsboolean
expirationDateBigNumber
isRevokedboolean
ownerIdentityIdBigNumber
readerIdentityIdBigNumber
signatureDateBigNumber

ListLinksResult

Ƭ ListLinksResult: BaseResult & { links: Link[] }


NetworkName

Ƭ NetworkName: "goerli" | "mainnet" | "alfajores" | "celo" | "mumbai" | "polygon"


PaymentMethod

Ƭ PaymentMethod: "eth" | "weth" | "stable" | "utility"


VerifyLinkResult

Ƭ VerifyLinkResult: BaseResult & { verified?: boolean }

Variables

Messages

Const Messages: Object

Type declaration

NameType
NoIdentity(address?: string) => string
WaitingToFinalize(txHash: string) => string

Templates

Const Templates: Object

Type declaration

NameType
loginTemplate(challenge: string, expires: string) => string
twoFATemplate(identityId: string, phoneNumber: string, code: string) => string

addresses

Const addresses: Addresses


environments

Const environments: Environment[]

Functions

arweave

arweave(«destructured»): MasaArweave

Parameters

NameType
«destructured»Object
› hoststring
› logging?boolean
› portnumber
› protocolstring

Returns

MasaArweave


burnCreditScore

burnCreditScore(masa, creditScoreId): Promise<boolean>

Parameters

NameType
masaMasa
creditScoreIdBigNumber

Returns

Promise<boolean>


burnCreditScoreById

burnCreditScoreById(masa, creditScoreId): Promise<boolean>

Parameters

NameType
masaMasa
creditScoreIdBigNumber

Returns

Promise<boolean>


burnGreen

burnGreen(masa, greenId): Promise<boolean>

Parameters

NameType
masaMasa
greenIdnumber

Returns

Promise<boolean>


burnGreenById

burnGreenById(masa, greenId): Promise<boolean>

Parameters

NameType
masaMasa
greenIdnumber

Returns

Promise<boolean>


burnIdentity

burnIdentity(masa): Promise<boolean>

Parameters

NameType
masaMasa

Returns

Promise<boolean>


burnIdentityById

burnIdentityById(masa, identityId): Promise<boolean>

Parameters

NameType
masaMasa
identityIdBigNumber

Returns

Promise<boolean>


burnSoulName

burnSoulName(masa, soulName): Promise<void>

Parameters

NameType
masaMasa
soulNamestring

Returns

Promise<void>


burnSoulNameByName

burnSoulNameByName(masa, soulName): Promise<void>

Parameters

NameType
masaMasa
soulNamestring

Returns

Promise<void>


calculateSoulNameLength

calculateSoulNameLength(soulName): number

Parameters

NameType
soulNamestring

Returns

number


checkLogin

checkLogin(masa): Promise<boolean>

Parameters

NameType
masaMasa

Returns

Promise<boolean>


createCreditScore

createCreditScore(masa, paymentMethod?): Promise<undefined | BaseResult>

Parameters

NameTypeDefault value
masaMasaundefined
paymentMethodPaymentMethod"eth"

Returns

Promise<undefined | BaseResult>


createGreen

createGreen(masa, phoneNumber, code, paymentMethod?): Promise<CreateGreenResult>

Parameters

NameTypeDefault value
masaMasaundefined
phoneNumberstringundefined
codestringundefined
paymentMethodPaymentMethod"eth"

Returns

Promise<CreateGreenResult>


createIdentity

createIdentity(masa): Promise<boolean>

Parameters

NameType
masaMasa

Returns

Promise<boolean>


createIdentityWithSoulName

createIdentityWithSoulName(masa, soulName, duration, paymentMethod): Promise<boolean>

Parameters

NameType
masaMasa
soulNamestring
durationnumber
paymentMethodPaymentMethod

Returns

Promise<boolean>


createLink(masa, contract, tokenId, readerIdentityId): Promise<CreateLinkResult>

Parameters

NameType
masaMasa
contractContract
tokenIdBigNumber
readerIdentityIdBigNumber

Returns

Promise<CreateLinkResult>


createRandomWallet

createRandomWallet(): Wallet

Returns

Wallet


createSoulName

createSoulName(masa, soulName, duration, paymentMethod): Promise<CreateSoulNameResult>

Parameters

NameType
masaMasa
soulNamestring
durationnumber
paymentMethodPaymentMethod

Returns

Promise<CreateSoulNameResult>


establishLink(masa, contract, paymentMethod, tokenId, readerIdentityId, signature, signatureDate, expirationDate): Promise<BaseResult>

Parameters

NameType
masaMasa
contractContract
paymentMethodPaymentMethod
tokenIdBigNumber
readerIdentityIdBigNumber
signaturestring
signatureDatenumber
expirationDatenumber

Returns

Promise<BaseResult>


establishLinkFromPassport

establishLinkFromPassport(masa, contract, passport, paymentMethod): Promise<BaseResult>

Parameters

NameType
masaMasa
contractContract
passportstring
paymentMethodPaymentMethod

Returns

Promise<BaseResult>


generateSignatureDomain

generateSignatureDomain(wallet, name, verifyingContract): Promise<{ chainId: number ; name: string ; verifyingContract: string ; version: string = "1.0.0" }>

Parameters

NameType
walletWallet
namestring
verifyingContractstring

Returns

Promise<{ chainId: number ; name: string ; verifyingContract: string ; version: string = "1.0.0" }>


getBalances

getBalances(masa, address?): Promise<undefined | { ethBalance: BigNumber ; identityBalance: BigNumber ; masaBalance: BigNumber ; soulNameBalance: BigNumber ; soulbound2FABalance: BigNumber ; soulboundCreditScoreBalance: BigNumber ; usdcBalance: BigNumber ; wethBalance: BigNumber }>

Parameters

NameType
masaMasa
address?string

Returns

Promise<undefined | { ethBalance: BigNumber ; identityBalance: BigNumber ; masaBalance: BigNumber ; soulNameBalance: BigNumber ; soulbound2FABalance: BigNumber ; soulboundCreditScoreBalance: BigNumber ; usdcBalance: BigNumber ; wethBalance: BigNumber }>


getRegistrationPrice

getRegistrationPrice(masa, soulName, duration, paymentMethod): Promise<BigNumber>

Parameters

NameType
masaMasa
soulNamestring
durationnumber
paymentMethodPaymentMethod

Returns

Promise<BigNumber>


getSession

getSession(masa): Promise<undefined | ISession>

Parameters

NameType
masaMasa

Returns

Promise<undefined | ISession>


listCreditScores

listCreditScores(masa, address?): Promise<{ metadata?: ICreditScore ; tokenId: BigNumber ; tokenUri: string }[]>

Parameters

NameType
masaMasa
address?string

Returns

Promise<{ metadata?: ICreditScore ; tokenId: BigNumber ; tokenUri: string }[]>


listGreens

listGreens(masa, address?): Promise<{ metadata?: IGreen ; tokenId: BigNumber ; tokenUri: string }[]>

Parameters

NameType
masaMasa
address?string

Returns

Promise<{ metadata?: IGreen ; tokenId: BigNumber ; tokenUri: string }[]>


listLinks(masa, contract, tokenId): Promise<ListLinksResult>

Parameters

NameType
masaMasa
contractContract
tokenIdBigNumber

Returns

Promise<ListLinksResult>


listSoulNames

listSoulNames(masa, address?): Promise<SoulNameDetails[]>

Parameters

NameType
masaMasa
address?string

Returns

Promise<SoulNameDetails[]>


loadAddressFromIdentityId

loadAddressFromIdentityId(masa, identityId): Promise<undefined | string>

Parameters

NameType
masaMasa
identityIdBigNumber

Returns

Promise<undefined | string>


loadCreditScoreByTokenId

loadCreditScoreByTokenId(masa, creditScoreId): Promise<{ metadata?: ICreditScore ; tokenId: BigNumber ; tokenUri: string }>

Parameters

NameType
masaMasa
creditScoreIdBigNumber

Returns

Promise<{ metadata?: ICreditScore ; tokenId: BigNumber ; tokenUri: string }>


loadCreditScoresByIdentityId

loadCreditScoresByIdentityId(masa, identityId): Promise<{ metadata?: ICreditScore ; tokenId: BigNumber ; tokenUri: string }[]>

Parameters

NameType
masaMasa
identityIdBigNumber

Returns

Promise<{ metadata?: ICreditScore ; tokenId: BigNumber ; tokenUri: string }[]>


loadGreensByIdentityId

loadGreensByIdentityId(masa, identityId): Promise<{ metadata?: IGreen ; tokenId: BigNumber ; tokenUri: string }[]>

Parameters

NameType
masaMasa
identityIdBigNumber

Returns

Promise<{ metadata?: IGreen ; tokenId: BigNumber ; tokenUri: string }[]>


loadIdentityByAddress

loadIdentityByAddress(masa, address?): Promise<{ address?: string ; identityId?: BigNumber }>

Parameters

NameType
masaMasa
address?string

Returns

Promise<{ address?: string ; identityId?: BigNumber }>


loadIdentityContracts

loadIdentityContracts(«destructured»): IIdentityContracts

Parameters

NameType
«destructured»LoadContractArgs

Returns

IIdentityContracts


loadIdentityDetails

loadIdentityDetails(masa, identityId): Promise<{ metadata?: IIdentity ; tokenId: BigNumber ; tokenUri: string }>

Parameters

NameType
masaMasa
identityIdBigNumber

Returns

Promise<{ metadata?: IIdentity ; tokenId: BigNumber ; tokenUri: string }>


loadLinks(masa, contract, tokenId): Promise<Link[]>

Parameters

NameType
masaMasa
contractContract
tokenIdBigNumber

Returns

Promise<Link[]>


loadSoulNameByName

loadSoulNameByName(masa, soulName): Promise<undefined | SoulNameDetails>

Parameters

NameType
masaMasa
soulNamestring

Returns

Promise<undefined | SoulNameDetails>


loadSoulNameByTokenId

loadSoulNameByTokenId(masa, tokenId): Promise<undefined | SoulNameDetails>

Parameters

NameType
masaMasa
tokenIdstring | BigNumber

Returns

Promise<undefined | SoulNameDetails>


loadSoulNamesByAddress

loadSoulNamesByAddress(masa, address): Promise<SoulNameDetails[]>

Parameters

NameType
masaMasa
addressstring

Returns

Promise<SoulNameDetails[]>


loadSoulNamesByIdentityId

loadSoulNamesByIdentityId(masa, identityId): Promise<SoulNameDetails[]>

Parameters

NameType
masaMasa
identityIdBigNumber

Returns

Promise<SoulNameDetails[]>


loadSoulNamesByName

loadSoulNamesByName(masa, soulNames): Promise<SoulNameDetails[]>

Parameters

NameType
masaMasa
soulNamesstring[]

Returns

Promise<SoulNameDetails[]>


login

login(masa): Promise<undefined | { address: string ; cookie?: string ; userId: string | BigNumber }>

Parameters

NameType
masaMasa

Returns

Promise<undefined | { address: string ; cookie?: string ; userId: string | BigNumber }>


logout

logout(masa): Promise<undefined | { status: string }>

Parameters

NameType
masaMasa

Returns

Promise<undefined | { status: string }>


patchMetadataUrl

patchMetadataUrl(masa, tokeUri): string

Parameters

NameType
masaMasa
tokeUristring

Returns

string


printSoulName

printSoulName(soulName, index?): void

Parameters

NameType
soulNameSoulNameDetails
index?number

Returns

void


purchaseIdentity

purchaseIdentity(masa): Promise<void>

Parameters

NameType
masaMasa

Returns

Promise<void>


purchaseIdentityWithSoulName

purchaseIdentityWithSoulName(masa, soulName, soulNameLength, duration, paymentMethod): Promise<void>

Parameters

NameType
masaMasa
soulNamestring
soulNameLengthnumber
durationnumber
paymentMethodPaymentMethod

Returns

Promise<void>


recoverAddress

recoverAddress(msg, signature, doHash?): undefined | string

Parameters

NameTypeDefault value
msgstringundefined
signaturestringundefined
doHashbooleanfalse

Returns

undefined | string


sendSoulName

sendSoulName(masa, soulName, receiver): Promise<void>

Parameters

NameType
masaMasa
soulNamestring
receiverstring

Returns

Promise<void>


sendSoulNameByName

sendSoulNameByName(masa, soulName, receiver): Promise<void>

Parameters

NameType
masaMasa
soulNamestring
receiverstring

Returns

Promise<void>


showIdentity

showIdentity(masa, address?): Promise<undefined | { metadata?: IIdentity ; tokenId: BigNumber ; tokenUri: string }>

Parameters

NameType
masaMasa
address?string

Returns

Promise<undefined | { metadata?: IIdentity ; tokenId: BigNumber ; tokenUri: string }>


signMessage

signMessage(msg, wallet, doHash?): Promise<undefined | string>

Parameters

NameTypeDefault value
msgstringundefined
walletSigner | Walletundefined
doHashbooleanfalse

Returns

Promise<undefined | string>


signSoulLinkerLink(masa, readerIdentityId, ownerIdentityId, tokenAddress, tokenId, signatureDate?, expirationOffset?): Promise<{ expirationDate: number ; signature: string ; signatureDate: number }>

Parameters

NameType
masaMasa
readerIdentityIdBigNumber
ownerIdentityIdBigNumber
tokenAddressstring
tokenIdBigNumber
signatureDatenumber
expirationOffsetnumber

Returns

Promise<{ expirationDate: number ; signature: string ; signatureDate: number }>


signTypedData

signTypedData(contract, wallet, name, types, value): Promise<{ domain: { chainId: number ; name: string ; verifyingContract: string ; version: string = "1.0.0" } ; signature: string }>

Parameters

NameType
contractContract
walletWallet
namestring
typesRecord<string, TypedDataField[]>
valueRecord<string, any>

Returns

Promise<{ domain: { chainId: number ; name: string ; verifyingContract: string ; version: string = "1.0.0" } ; signature: string }>


unpackSessionId

unpackSessionId(cookie?): undefined | string

Parameters

NameType
cookie?string

Returns

undefined | string


validateSoulName

validateSoulName(masa, soulName): Object

Parameters

NameType
masaMasa
soulNamestring

Returns

Object

NameType
isValidboolean
lengthnumber
message?string

verifyLink(masa, contract, tokenId, readerIdentityId?): Promise<VerifyLinkResult>

Parameters

NameType
masaMasa
contractContract
tokenIdBigNumber
readerIdentityId?BigNumber

Returns

Promise<VerifyLinkResult>


version

version(): Object

Returns

Object

NameType
contractsVersionstring
sdkVersionstring