Skip to main content

modules

[# Masa SDK

  • v3.30.3](/docs/developers/sdk/) / Exports

# Masa SDK

  • v3.30.3

Table of contents

Enumerations

Classes

Interfaces

Type Aliases

Variables

Functions

Type Aliases

ApprovalEvent

Ƭ ApprovalEvent: TypedEvent\<[string, string, BigNumber], ApprovalEventObject>


ApprovalEventFilter

Ƭ ApprovalEventFilter: TypedEventFilter\<ApprovalEvent>


BalanceTypes

Ƭ BalanceTypes: "Native" | PaymentMethod | SBTContractNames


Balances

Ƭ Balances: Partial\<{ [index in BalanceTypes]: number | undefined }>


BreakLinkResult

Ƭ BreakLinkResult: BaseResult


CreateLinkResult

Ƭ CreateLinkResult: BaseResult & { passport?: string }


ERC20Currencies

Ƭ ERC20Currencies: typeof erc20Currencies[number]


Environment

Ƭ Environment: { wallet?: Signer } & MasaArgs


EnvironmentName

Ƭ EnvironmentName: "local" | "dev" | "stage" | "production"


EstablishLinkResult

Ƭ EstablishLinkResult: BaseResult


Ƭ Link: Object

Type declaration

NameType
existsboolean
expirationDateBigNumber
isRevokedboolean
ownerIdentityIdBigNumber
readerIdentityIdBigNumber
signatureDateBigNumber

ListLinksResult

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


NativeCurrencies

Ƭ NativeCurrencies: typeof nativeCurrencies[number]


NetworkName

Ƭ NetworkName: "masatest" | "masa" | "goerli" | "sepolia" | "ethereum" | "alfajores" | "celo" | "mumbai" | "polygon" | "bsctest" | "bsc" | "opbnbtest" | "opbnb" | "basegoerli" | "basesepolia" | "base" | "scrollsepolia" | "scroll" | "unknown"


PaymentMethod

Ƭ PaymentMethod: NativeCurrencies | ERC20Currencies


QueryLinkResult

Ƭ QueryLinkResult: BaseResult


SBTContractNames

Ƭ SBTContractNames: "Identity" | "SoulName" | "Green" | "CreditScore"


Tokens

Ƭ Tokens: Partial\<{ [key in PaymentMethod]: string }>


TransferEvent

Ƭ TransferEvent: TypedEvent\<[string, string, BigNumber], TransferEventObject>


TransferEventFilter

Ƭ TransferEventFilter: TypedEventFilter\<TransferEvent>


VerifyLinkResult

Ƭ VerifyLinkResult: BaseResult & { verified?: boolean }

Variables

Messages

Const Messages: Object

Type declaration

NameType
ContractNotDeployed(networkName: NetworkName) => string
NoIdentity(address?: string) => string
NotLoggedIn() => string
WaitingToFinalize(txHash: string, explorerUrl?: string) => string

SupportedNetworks

Const SupportedNetworks: Partial\<{ [key in NetworkName]: Network }>


Templates

Const Templates: Object

Type declaration

NameTypeDescription
loginTemplate(challenge: string, expires: string) => string-

addresses

Const addresses: Partial\<{ [key in NetworkName]: Addresses }>


alfajores

Const alfajores: Addresses


base

Const base: Addresses


basegoerli

Const basegoerli: Addresses


bsc

Const bsc: Addresses


bsctest

Const bsctest: Addresses


celo

Const celo: Addresses


environments

Const environments: Environment[]


erc20Currencies

Const erc20Currencies: readonly ["MASA", "WETH", "G$", "USDC", "cUSD"]


ethereum

Const ethereum: Addresses


goerli

Const goerli: Addresses


mumbai

Const mumbai: Addresses


nativeCurrencies

Const nativeCurrencies: readonly ["ETH", "CELO", "MATIC", "BNB"]


polygon

Const polygon: Addresses


sepolia

Const sepolia: Addresses

Functions

burnIdentity

burnIdentity(masa): Promise\<BaseResult>

Parameters

NameType
masaMasaInterface

Returns

Promise\<BaseResult>


burnSoulName

burnSoulName(masa, soulName): Promise\<BaseResult>

Parameters

NameType
masaMasaInterface
soulNamestring

Returns

Promise\<BaseResult>


calculateSoulNameLength

calculateSoulNameLength(soulName): number

Parameters

NameType
soulNamestring

Returns

number


checkExists

checkExists(address, signer): Promise\<boolean>

Parameters

NameType
addressstring
signerSigner

Returns

Promise\<boolean>


checkLogin

checkLogin(masa): Promise\<boolean>

Parameters

NameType
masaMasaInterface

Returns

Promise\<boolean>


claimAllRewards

claimAllRewards(masa): Promise\<BaseResult>

Parameters

NameType
masaMasaInterface

Returns

Promise\<BaseResult>


createCreditScore

createCreditScore(masa, paymentMethod): Promise\<GenerateCreditScoreResult>

Parameters

NameType
masaMasaInterface
paymentMethodPaymentMethod

Returns

Promise\<GenerateCreditScoreResult>


createGreen

createGreen(masa, paymentMethod, phoneNumber, code): Promise\<GreenBaseResult>

Parameters

NameType
masaMasaInterface
paymentMethodPaymentMethod
phoneNumberstring
codestring

Returns

Promise\<GreenBaseResult>


createIdentity

createIdentity(masa): Promise\<BaseResultWithTokenId>

Parameters

NameType
masaMasaInterface

Returns

Promise\<BaseResultWithTokenId>


createIdentityWithSoulName

createIdentityWithSoulName(masa, paymentMethod, soulName, duration, style?): Promise\<{ identityId?: string | BigNumber } & CreateSoulNameResult>

Parameters

NameType
masaMasaInterface
paymentMethodPaymentMethod
soulNamestring
durationnumber
style?string

Returns

Promise\<{ identityId?: string | BigNumber } & CreateSoulNameResult>


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

Parameters

NameType
masaMasaInterface
contractContract
tokenIdBigNumber
readerIdentityIdBigNumber

Returns

Promise\<CreateLinkResult>


createSoulName

createSoulName(masa, paymentMethod, soulName, duration, receiver?, style?): Promise\<CreateSoulNameResult>

Parameters

NameType
masaMasaInterface
paymentMethodPaymentMethod
soulNamestring
durationnumber
receiver?string
style?string

Returns

Promise\<CreateSoulNameResult>


deployASBT

deployASBT(«destructured»): Promise\<undefined | DeployResult\<PaymentParamsStruct>>

Parameters

NameTypeDefault value
«destructured»Objectundefined
› adminAddress?stringundefined
› baseTokenUristringundefined
› limit?number1
› masaMasaInterfaceundefined
› namestringundefined
› paymentOptions?Objectundefined
› paymentOptions.projectFeeReceiverstringundefined
› symbolstringundefined

Returns

Promise\<undefined | DeployResult\<PaymentParamsStruct>>


deploySSSBT

deploySSSBT(«destructured»): Promise\<undefined | DeployResult\<PaymentParamsStruct>>

Parameters

NameTypeDefault value
«destructured»Objectundefined
› adminAddress?stringundefined
› authorityAddress?stringundefined
› baseTokenUristringundefined
› limitnumber1
› masaMasaInterfaceundefined
› namestringundefined
› paymentOptions?Objectundefined
› paymentOptions.projectFeeReceiverstringundefined
› symbolstringundefined

Returns

Promise\<undefined | DeployResult\<PaymentParamsStruct>>


deposit

deposit(masa, amount): Promise\<BaseResult>

Parameters

NameType
masaMasaInterface
amountstring

Returns

Promise\<BaseResult>


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

Parameters

NameType
masaMasaInterface
paymentMethodPaymentMethod
contractContract
tokenIdBigNumber
readerIdentityIdBigNumber
signaturestring
signatureDatenumber
expirationDatenumber

Returns

Promise\<BaseResult>


establishLinkFromPassport

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

Parameters

NameType
masaMasaInterface
paymentMethodPaymentMethod
contractContract
passportstring

Returns

Promise\<BaseResult>


generateGreen

generateGreen(masa, phoneNumber): Promise\<GenerateGreenResult>

Parameters

NameType
masaMasaInterface
phoneNumberstring

Returns

Promise\<GenerateGreenResult>


generateSignatureDomain

generateSignatureDomain(signer, name, verifyingContract, version?): Promise\<TypedDataDomain>

Parameters

NameTypeDefault value
signerSignerundefined
namestringundefined
verifyingContractstringundefined
versionstring"1.0.0"

Returns

Promise\<TypedDataDomain>


getBalances

getBalances(masa, address?): Promise\<Partial\<{ BNB: undefined | number ; CELO: undefined | number ; CreditScore: undefined | number ; ETH: undefined | number ; G$: undefined | number ; Green: undefined | number ; Identity: undefined | number ; MASA: undefined | number ; MATIC: undefined | number ; Native: undefined | number ; SoulName: undefined | number ; USDC: undefined | number ; WETH: undefined | number ; cUSD: undefined | number }>>

Parameters

NameType
masaMasaInterface
address?string

Returns

Promise\<Partial\<{ BNB: undefined | number ; CELO: undefined | number ; CreditScore: undefined | number ; ETH: undefined | number ; G$: undefined | number ; Green: undefined | number ; Identity: undefined | number ; MASA: undefined | number ; MATIC: undefined | number ; Native: undefined | number ; SoulName: undefined | number ; USDC: undefined | number ; WETH: undefined | number ; cUSD: undefined | number }>>


getNetworkNameByChainId

getNetworkNameByChainId(chainId): NetworkName

Parameters

NameType
chainIdnumber

Returns

NetworkName


getSession

getSession(masa): Promise\<undefined | ISession>

Parameters

NameType
masaMasaInterface

Returns

Promise\<undefined | ISession>


getSoulNameMetadataPrefix

getSoulNameMetadataPrefix(masa): string

try to evaluate the right prefix

Parameters

NameType
masaMasaInterface

Returns

string


getSwapParameters

getSwapParameters(eid, receiverAddress, tokenAmount, slippage?): Object

Parameters

NameTypeDefault value
eidEndpointIdundefined
receiverAddressstringundefined
tokenAmountBigNumberundefined
slippagenumber250

Returns

Object

NameType
sendParametersSendParamStruct | SendParamStruct | SendParamStruct
slippagenumber

getSwapQuote

getSwapQuote(masa, sendParameters): Promise\<BaseResult | QuoteResult>

Parameters

NameType
masaMasaInterface
sendParametersSendParamStruct | SendParamStruct | SendParamStruct

Returns

Promise\<BaseResult | QuoteResult>


isBigNumber

isBigNumber(item): item is BigNumber

Parameters

NameType
itemstring | BigNumber

Returns

item is BigNumber


isERC20Currency

isERC20Currency(paymentMethod): paymentMethod is "MASA" | "WETH" | "G$" | "USDC" | "cUSD"

Parameters

NameType
paymentMethodunknown

Returns

paymentMethod is "MASA" | "WETH" | "G$" | "USDC" | "cUSD"


isNativeCurrency

isNativeCurrency(paymentMethod): paymentMethod is "ETH" | "CELO" | "MATIC" | "BNB"

Parameters

NameType
paymentMethodunknown

Returns

paymentMethod is "ETH" | "CELO" | "MATIC" | "BNB"


isSession

isSession(session): session is ISession

Parameters

NameType
sessionunknown

Returns

session is ISession


isSoulNameMetadataStoreResult

isSoulNameMetadataStoreResult(result): result is SoulNameMetadataStoreResult

Parameters

NameType
resultSoulNameResultBase

Returns

result is SoulNameMetadataStoreResult


listCreditScores

listCreditScores(masa, address?): Promise\<CreditScoreDetails[]>

Parameters

NameType
masaMasaInterface
address?string

Returns

Promise\<CreditScoreDetails[]>


listCreditScoresAndPrint

listCreditScoresAndPrint(masa, address?): Promise\<CreditScoreDetails[]>

Parameters

NameType
masaMasaInterface
address?string

Returns

Promise\<CreditScoreDetails[]>


listGreens

listGreens(masa, address?): Promise\<GreenDetails[]>

Parameters

NameType
masaMasaInterface
address?string

Returns

Promise\<GreenDetails[]>


listGreensAndPrint

listGreensAndPrint(masa, address?): Promise\<GreenDetails[]>

Parameters

NameType
masaMasaInterface
address?string

Returns

Promise\<GreenDetails[]>


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

Parameters

NameType
masaMasaInterface
contractContract
tokenIdBigNumber

Returns

Promise\<ListLinksResult>


listSoulNames

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

list soul names

Parameters

NameType
masaMasaInterface
address?string

Returns

Promise\<SoulNameDetails[]>


listSoulNamesAndPrint

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

list soul names and print them

Parameters

NameType
masaMasaInterface
address?string

Returns

Promise\<SoulNameDetails[]>


loadCreditScoreDetails

loadCreditScoreDetails(masa, creditScoreIds): Promise\<CreditScoreDetails[]>

Parameters

NameType
masaMasaInterface
creditScoreIdsBigNumber[]

Returns

Promise\<CreditScoreDetails[]>


loadCreditScores

loadCreditScores(masa, identityIdOrAddress): Promise\<CreditScoreDetails[]>

Parameters

NameType
masaMasaInterface
identityIdOrAddressstring | BigNumber

Returns

Promise\<CreditScoreDetails[]>


loadGreenDetails

loadGreenDetails(masa, greenIds): Promise\<GreenDetails[]>

Parameters

NameType
masaMasaInterface
greenIdsBigNumber[]

Returns

Promise\<GreenDetails[]>


loadGreens

loadGreens(masa, identityIdOrAddress): Promise\<GreenDetails[]>

Parameters

NameType
masaMasaInterface
identityIdOrAddressstring | BigNumber

Returns

Promise\<GreenDetails[]>


loadIdentity

loadIdentity(masa, address?): Promise\<undefined | IdentityDetails>

Parameters

NameType
masaMasaInterface
address?string

Returns

Promise\<undefined | IdentityDetails>


loadIdentityByAddress

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

Parameters

NameType
masaMasaInterface
address?string

Returns

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


loadIdentityContracts

loadIdentityContracts(«destructured»): IIdentityContracts

Parameters

NameTypeDefault value
«destructured»Objectundefined
› networkName?NetworkName"ethereum"
› signerSignerundefined

Returns

IIdentityContracts


loadIdentityDetails

loadIdentityDetails(masa, identityIdOrAddress): Promise\<IdentityDetails>

Parameters

NameType
masaMasaInterface
identityIdOrAddressstring | BigNumber

Returns

Promise\<IdentityDetails>


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

Parameters

NameType
masaMasaInterface
contractContract
tokenIdBigNumber

Returns

Promise\<Link[]>


loadMarketplaceContracts

loadMarketplaceContracts(«destructured»): IMarketplaceContracts

Parameters

NameTypeDefault value
«destructured»Objectundefined
› networkName?NetworkName"ethereum"
› signerSignerundefined

Returns

IMarketplaceContracts


loadOFTContract

loadOFTContract(masa): undefined | MasaTokenNativeOFT | MasaToken | MasaTokenOFT

Parameters

NameType
masaMasaInterface

Returns

undefined | MasaTokenNativeOFT | MasaToken | MasaTokenOFT


loadSoulNameByName

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

Parameters

NameType
masaMasaInterface
soulNamestring

Returns

Promise\<undefined | SoulNameDetails>


loadSoulNameByTokenId

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

Parameters

NameType
masaMasaInterface
tokenIdstring | BigNumber

Returns

Promise\<undefined | SoulNameDetails>


loadSoulNameDetailsByAddress

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

Parameters

NameType
masaMasaInterface
addressstring

Returns

Promise\<SoulNameDetails[]>


loadSoulNames

loadSoulNames(masa, identityIdOrAddress): Promise\<string[]>

loads active soul names

Parameters

NameType
masaMasaInterface
identityIdOrAddressstring | BigNumber

Returns

Promise\<string[]>


loadSoulNamesByNames

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

Parameters

NameType
masaMasaInterface
soulNamesstring[]

Returns

Promise\<SoulNameDetails[]>


loadSoulNamesWithExpired

loadSoulNamesWithExpired(masa, identityIdOrAddress): Promise\<string[]>

loads all soul names even expired ones

Parameters

NameType
masaMasaInterface
identityIdOrAddressstring | BigNumber

Returns

Promise\<string[]>


login

login(masa): Promise\<LoginResult>

Parameters

NameType
masaMasaInterface

Returns

Promise\<LoginResult>


logout

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

Parameters

NameType
masaMasaInterface

Returns

Promise\<undefined | { status: string }>


mintGreen

mintGreen(masa, paymentMethod, authorityAddress, signatureDate, signature): Promise\<BaseResultWithTokenId>

Parameters

NameType
masaMasaInterface
paymentMethodPaymentMethod
authorityAddressstring
signatureDatenumber
signaturestring

Returns

Promise\<BaseResultWithTokenId>


parsePassport

parsePassport(passportEncoded): IPassport

Parameters

NameType
passportEncodedstring

Returns

IPassport


patchMetadataUrl

patchMetadataUrl(masa, metadataUrl): string

todo: fix this thing, its not good

Parameters

NameType
masaMasaInterface
metadataUrlstring

Returns

string


printSoulName

printSoulName(soulName, index?, verbose?): void

Parameters

NameTypeDefault value
soulNameSoulNameDetailsundefined
index?numberundefined
verbosebooleanfalse

Returns

void


purchaseIdentity

purchaseIdentity(masa): Promise\<BaseResultWithTokenId>

Identity only

Parameters

NameType
masaMasaInterface

Returns

Promise\<BaseResultWithTokenId>


purchaseIdentityWithSoulName

purchaseIdentityWithSoulName(masa, soulName, soulNameLength, duration, paymentMethod, style?): Promise\<{ identityId?: string | BigNumber } & CreateSoulNameResult>

Identity with soul name

Parameters

NameType
masaMasaInterface
soulNamestring
soulNameLengthnumber
durationnumber
paymentMethodPaymentMethod
style?string

Returns

Promise\<{ identityId?: string | BigNumber } & CreateSoulNameResult>


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

Parameters

NameType
masaMasaInterface
contractContract
paymentMethodPaymentMethod
tokenIdBigNumber
readerIdentityIdBigNumber
signaturestring
signatureDatenumber
expirationDatenumber

Returns

Promise\<BaseResult>


queryLinkFromPassport

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

Parameters

NameType
masaMasaInterface
paymentMethodPaymentMethod
contractContract
passportstring

Returns

Promise\<BaseResult>


recoverAddress

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

Parameters

NameTypeDefault value
msgstringundefined
signaturestringundefined
doHashbooleanfalse

Returns

undefined | string


renewSoulName

renewSoulName(masa, soulName, years): Promise\<BaseResult>

Parameters

NameType
masaMasaInterface
soulNamestring
yearsnumber

Returns

Promise\<BaseResult>


resolveIdentity

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

Resolves identity id into address

Parameters

NameType
masaMasaInterface
identityIdBigNumber

Returns

Promise\<undefined | string>


resolveReverseIdentity

resolveReverseIdentity(masa, address): Promise\<undefined | BigNumber>

Parameters

NameType
masaMasaInterface
addressstring

Returns

Promise\<undefined | BigNumber>


resolveSoulName

resolveSoulName(masa, soulName): Promise\<undefined | string>

Parameters

NameType
masaMasaInterface
soulNamestring

Returns

Promise\<undefined | string>


sendSoulName

sendSoulName(masa, soulName, receiver): Promise\<BaseResult>

Parameters

NameType
masaMasaInterface
soulNamestring
receiverstring

Returns

Promise\<BaseResult>


showIdentity

showIdentity(masa, address?): Promise\<undefined | IdentityDetails>

Parameters

NameType
masaMasaInterface
address?string

Returns

Promise\<undefined | IdentityDetails>


signMessage

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

Parameters

NameTypeDefault value
msgstringundefined
signerSignerundefined
doHashbooleanfalse

Returns

Promise\<undefined | string>


signTypedData

signTypedData(«destructured»): Promise\<{ domain: TypedDataDomain ; signature: string }>

Parameters

NameType
«destructured»Object
› contractBaseContract | EIP712
› name?string
› signerSigner
› typesRecord\<string, TypedDataField[]>
› valueRecord\<string, string | number | boolean | BigNumber>

Returns

Promise\<{ domain: TypedDataDomain ; signature: string }>


stakeAll

stakeAll(masa): Promise\<BaseResult>

Parameters

NameType
masaMasaInterface

Returns

Promise\<BaseResult>


swap

swap(masa, to, amount, slippage?): Promise\<SwapResult>

Parameters

NameType
masaMasaInterface
toNetworkName
amountstring
slippage?number

Returns

Promise\<SwapResult>


tailSoulNames

tailSoulNames(masa, limit?): Promise\<SoulNameDetails[]>

Parameters

NameTypeDefault value
masaMasaInterfaceundefined
limitnumber5

Returns

Promise\<SoulNameDetails[]>


tailSoulNamesAndPrint

tailSoulNamesAndPrint(masa, limit?): Promise\<SoulNameDetails[]>

Parameters

NameTypeDefault value
masaMasaInterfaceundefined
limitnumber5

Returns

Promise\<SoulNameDetails[]>


unpackSessionId

unpackSessionId(cookie?): undefined | string

Parameters

NameType
cookie?string

Returns

undefined | string


validateSoulName

validateSoulName(masa, soulName, verbose?): Object

Parameters

NameType
masaMasaInterface
soulNamestring
verbose?boolean

Returns

Object

NameType
isValidboolean
lengthnumber
message?string

verifyByName

verifyByName(masa, soulName): Promise\<{ imageHashMatch: boolean ; imageOwnerIsMasaAccount: boolean ; imageSignatureMatch: boolean ; metadataOwnerIsMasaAccount: boolean ; metadataSignatureMatch: boolean ; nameMatch: boolean }>

Parameters

NameType
masaMasaInterface
soulNamestring

Returns

Promise\<{ imageHashMatch: boolean ; imageOwnerIsMasaAccount: boolean ; imageSignatureMatch: boolean ; metadataOwnerIsMasaAccount: boolean ; metadataSignatureMatch: boolean ; nameMatch: boolean }>


verifyGreen

verifyGreen(masa, phoneNumber, code): Promise\<undefined | VerifyGreenResult>

Parameters

NameType
masaMasaInterface
phoneNumberstring
codestring

Returns

Promise\<undefined | VerifyGreenResult>


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

Parameters

NameType
masaMasaInterface
contractContract
tokenIdBigNumber
readerIdentityId?BigNumber

Returns

Promise\<VerifyLinkResult>


version

version(): Object

Returns

Object

NameType
contractsVersionstring
sdkVersionstring

withdraw

withdraw(masa, amount): Promise\<BaseResult>

Parameters

NameType
masaMasaInterface
amountstring

Returns

Promise\<BaseResult>