modules
[# Masa SDK
- v1.2.0-alpha.1](/docs/developers/sdk/) / Exports
# Masa SDK
- v1.2.0-alpha.1
Table of contents
Classes
- Masa
- MasaAccount
- MasaArweave
- MasaClient
- MasaContracts
- MasaCreditScore
- MasaGreen
- MasaIdentity
- MasaSession
- MasaSoulLinker
- MasaSoulName
Interfaces
- Addresses
- Attribute
- BaseResult
- CreateGreenResult
- CreateSoulNameResult
- ICreditScore
- IGreen
- IIdentity
- IIdentityContracts
- IPassport
- ISession
- ISoulName
- LoadContractArgs
- MasaArgs
- MasaConfig
- SoulNameDetails
Type Aliases
- CreateCreditScoreResult
- CreateLinkResult
- Environment
- EnvironmentName
- EstablishLinkResult
- Link
- ListLinksResult
- NetworkName
- PaymentMethod
- VerifyLinkResult
Variables
Functions
- arweave
- burnCreditScore
- burnCreditScoreById
- burnGreen
- burnGreenById
- burnIdentity
- burnIdentityById
- burnSoulName
- burnSoulNameByName
- calculateSoulNameLength
- checkLogin
- createCreditScore
- createGreen
- createIdentity
- createIdentityWithSoulName
- createLink
- createRandomWallet
- createSoulName
- establishLink
- establishLinkFromPassport
- generateSignatureDomain
- getBalances
- getRegistrationPrice
- getSession
- listCreditScores
- listGreens
- listLinks
- listSoulNames
- loadAddressFromIdentityId
- loadCreditScoreByTokenId
- loadCreditScoresByIdentityId
- loadGreensByIdentityId
- loadIdentityByAddress
- loadIdentityContracts
- loadIdentityDetails
- loadLinks
- loadSoulNameByName
- loadSoulNameByTokenId
- loadSoulNamesByAddress
- loadSoulNamesByIdentityId
- loadSoulNamesByName
- login
- logout
- patchMetadataUrl
- printSoulName
- purchaseIdentity
- purchaseIdentityWithSoulName
- recoverAddress
- sendSoulName
- sendSoulNameByName
- showIdentity
- signMessage
- signSoulLinkerLink
- signTypedData
- unpackSessionId
- validateSoulName
- verifyLink
- version
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
Ƭ Link: Object
Type declaration
Name | Type |
---|---|
exists | boolean |
expirationDate | BigNumber |
isRevoked | boolean |
ownerIdentityId | BigNumber |
readerIdentityId | BigNumber |
signatureDate | BigNumber |
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
Name | Type |
---|---|
NoIdentity | (address? : string ) => string |
WaitingToFinalize | (txHash : string ) => string |
Templates
• Const
Templates: Object
Type declaration
Name | Type |
---|---|
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
Name | Type |
---|---|
«destructured» | Object |
› host | string |
› logging? | boolean |
› port | number |
› protocol | string |
Returns
burnCreditScore
▸ burnCreditScore(masa
, creditScoreId
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
masa | Masa |
creditScoreId | BigNumber |
Returns
Promise
<boolean
>
burnCreditScoreById
▸ burnCreditScoreById(masa
, creditScoreId
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
masa | Masa |
creditScoreId | BigNumber |
Returns
Promise
<boolean
>
burnGreen
▸ burnGreen(masa
, greenId
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
masa | Masa |
greenId | number |
Returns
Promise
<boolean
>
burnGreenById
▸ burnGreenById(masa
, greenId
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
masa | Masa |
greenId | number |
Returns
Promise
<boolean
>
burnIdentity
▸ burnIdentity(masa
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
masa | Masa |
Returns
Promise
<boolean
>
burnIdentityById
▸ burnIdentityById(masa
, identityId
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
masa | Masa |
identityId | BigNumber |
Returns
Promise
<boolean
>
burnSoulName
▸ burnSoulName(masa
, soulName
): Promise
<void
>
Parameters
Name | Type |
---|---|
masa | Masa |
soulName | string |
Returns
Promise
<void
>
burnSoulNameByName
▸ burnSoulNameByName(masa
, soulName
): Promise
<void
>
Parameters
Name | Type |
---|---|
masa | Masa |
soulName | string |
Returns
Promise
<void
>
calculateSoulNameLength
▸ calculateSoulNameLength(soulName
): number
Parameters
Name | Type |
---|---|
soulName | string |
Returns
number
checkLogin
▸ checkLogin(masa
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
masa | Masa |
Returns
Promise
<boolean
>
createCreditScore
▸ createCreditScore(masa
, paymentMethod?
): Promise
<undefined
| BaseResult
>
Parameters
Name | Type | Default value |
---|---|---|
masa | Masa | undefined |
paymentMethod | PaymentMethod | "eth" |
Returns
Promise
<undefined
| BaseResult
>
createGreen
▸ createGreen(masa
, phoneNumber
, code
, paymentMethod?
): Promise
<CreateGreenResult
>
Parameters
Name | Type | Default value |
---|---|---|
masa | Masa | undefined |
phoneNumber | string | undefined |
code | string | undefined |
paymentMethod | PaymentMethod | "eth" |
Returns
Promise
<CreateGreenResult
>
createIdentity
▸ createIdentity(masa
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
masa | Masa |
Returns
Promise
<boolean
>
createIdentityWithSoulName
▸ createIdentityWithSoulName(masa
, soulName
, duration
, paymentMethod
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
masa | Masa |
soulName | string |
duration | number |
paymentMethod | PaymentMethod |
Returns
Promise
<boolean
>
createLink
▸ createLink(masa
, contract
, tokenId
, readerIdentityId
): Promise
<CreateLinkResult
>
Parameters
Name | Type |
---|---|
masa | Masa |
contract | Contract |
tokenId | BigNumber |
readerIdentityId | BigNumber |
Returns
Promise
<CreateLinkResult
>
createRandomWallet
▸ createRandomWallet(): Wallet
Returns
Wallet
createSoulName
▸ createSoulName(masa
, soulName
, duration
, paymentMethod
): Promise
<CreateSoulNameResult
>
Parameters
Name | Type |
---|---|
masa | Masa |
soulName | string |
duration | number |
paymentMethod | PaymentMethod |
Returns
Promise
<CreateSoulNameResult
>
establishLink
▸ establishLink(masa
, contract
, paymentMethod
, tokenId
, readerIdentityId
, signature
, signatureDate
, expirationDate
): Promise
<BaseResult
>
Parameters
Name | Type |
---|---|
masa | Masa |
contract | Contract |
paymentMethod | PaymentMethod |
tokenId | BigNumber |
readerIdentityId | BigNumber |
signature | string |
signatureDate | number |
expirationDate | number |
Returns
Promise
<BaseResult
>
establishLinkFromPassport
▸ establishLinkFromPassport(masa
, contract
, passport
, paymentMethod
): Promise
<BaseResult
>
Parameters
Name | Type |
---|---|
masa | Masa |
contract | Contract |
passport | string |
paymentMethod | PaymentMethod |
Returns
Promise
<BaseResult
>
generateSignatureDomain
▸ generateSignatureDomain(wallet
, name
, verifyingContract
): Promise
<{ chainId
: number
; name
: string
; verifyingContract
: string
; version
: string
= "1.0.0" }>
Parameters
Name | Type |
---|---|
wallet | Wallet |
name | string |
verifyingContract | string |
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
Name | Type |
---|---|
masa | Masa |
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
Name | Type |
---|---|
masa | Masa |
soulName | string |
duration | number |
paymentMethod | PaymentMethod |
Returns
Promise
<BigNumber
>
getSession
▸ getSession(masa
): Promise
<undefined
| ISession
>
Parameters
Name | Type |
---|---|
masa | Masa |
Returns
Promise
<undefined
| ISession
>
listCreditScores
▸ listCreditScores(masa
, address?
): Promise
<{ metadata?
: ICreditScore
; tokenId
: BigNumber
; tokenUri
: string
}[]>
Parameters
Name | Type |
---|---|
masa | Masa |
address? | string |
Returns
Promise
<{ metadata?
: ICreditScore
; tokenId
: BigNumber
; tokenUri
: string
}[]>
listGreens
▸ listGreens(masa
, address?
): Promise
<{ metadata?
: IGreen
; tokenId
: BigNumber
; tokenUri
: string
}[]>
Parameters
Name | Type |
---|---|
masa | Masa |
address? | string |
Returns
Promise
<{ metadata?
: IGreen
; tokenId
: BigNumber
; tokenUri
: string
}[]>
listLinks
▸ listLinks(masa
, contract
, tokenId
): Promise
<ListLinksResult
>
Parameters
Name | Type |
---|---|
masa | Masa |
contract | Contract |
tokenId | BigNumber |
Returns
Promise
<ListLinksResult
>
listSoulNames
▸ listSoulNames(masa
, address?
): Promise
<SoulNameDetails
[]>
Parameters
Name | Type |
---|---|
masa | Masa |
address? | string |
Returns
Promise
<SoulNameDetails
[]>
loadAddressFromIdentityId
▸ loadAddressFromIdentityId(masa
, identityId
): Promise
<undefined
| string
>
Parameters
Name | Type |
---|---|
masa | Masa |
identityId | BigNumber |
Returns
Promise
<undefined
| string
>
loadCreditScoreByTokenId
▸ loadCreditScoreByTokenId(masa
, creditScoreId
): Promise
<{ metadata?
: ICreditScore
; tokenId
: BigNumber
; tokenUri
: string
}>
Parameters
Name | Type |
---|---|
masa | Masa |
creditScoreId | BigNumber |
Returns
Promise
<{ metadata?
: ICreditScore
; tokenId
: BigNumber
; tokenUri
: string
}>
loadCreditScoresByIdentityId
▸ loadCreditScoresByIdentityId(masa
, identityId
): Promise
<{ metadata?
: ICreditScore
; tokenId
: BigNumber
; tokenUri
: string
}[]>
Parameters
Name | Type |
---|---|
masa | Masa |
identityId | BigNumber |
Returns
Promise
<{ metadata?
: ICreditScore
; tokenId
: BigNumber
; tokenUri
: string
}[]>
loadGreensByIdentityId
▸ loadGreensByIdentityId(masa
, identityId
): Promise
<{ metadata?
: IGreen
; tokenId
: BigNumber
; tokenUri
: string
}[]>
Parameters
Name | Type |
---|---|
masa | Masa |
identityId | BigNumber |
Returns
Promise
<{ metadata?
: IGreen
; tokenId
: BigNumber
; tokenUri
: string
}[]>
loadIdentityByAddress
▸ loadIdentityByAddress(masa
, address?
): Promise
<{ address?
: string
; identityId?
: BigNumber
}>
Parameters
Name | Type |
---|---|
masa | Masa |
address? | string |
Returns
Promise
<{ address?
: string
; identityId?
: BigNumber
}>
loadIdentityContracts
▸ loadIdentityContracts(«destructured»
): IIdentityContracts
Parameters
Name | Type |
---|---|
«destructured» | LoadContractArgs |
Returns
loadIdentityDetails
▸ loadIdentityDetails(masa
, identityId
): Promise
<{ metadata?
: IIdentity
; tokenId
: BigNumber
; tokenUri
: string
}>
Parameters
Name | Type |
---|---|
masa | Masa |
identityId | BigNumber |
Returns
Promise
<{ metadata?
: IIdentity
; tokenId
: BigNumber
; tokenUri
: string
}>
loadLinks
▸ loadLinks(masa
, contract
, tokenId
): Promise
<Link
[]>
Parameters
Name | Type |
---|---|
masa | Masa |
contract | Contract |
tokenId | BigNumber |
Returns
Promise
<Link
[]>
loadSoulNameByName
▸ loadSoulNameByName(masa
, soulName
): Promise
<undefined
| SoulNameDetails
>
Parameters
Name | Type |
---|---|
masa | Masa |
soulName | string |
Returns
Promise
<undefined
| SoulNameDetails
>
loadSoulNameByTokenId
▸ loadSoulNameByTokenId(masa
, tokenId
): Promise
<undefined
| SoulNameDetails
>
Parameters
Name | Type |
---|---|
masa | Masa |
tokenId | string | BigNumber |
Returns
Promise
<undefined
| SoulNameDetails
>
loadSoulNamesByAddress
▸ loadSoulNamesByAddress(masa
, address
): Promise
<SoulNameDetails
[]>
Parameters
Name | Type |
---|---|
masa | Masa |
address | string |
Returns
Promise
<SoulNameDetails
[]>
loadSoulNamesByIdentityId
▸ loadSoulNamesByIdentityId(masa
, identityId
): Promise
<SoulNameDetails
[]>
Parameters
Name | Type |
---|---|
masa | Masa |
identityId | BigNumber |
Returns
Promise
<SoulNameDetails
[]>
loadSoulNamesByName
▸ loadSoulNamesByName(masa
, soulNames
): Promise
<SoulNameDetails
[]>
Parameters
Name | Type |
---|---|
masa | Masa |
soulNames | string [] |
Returns
Promise
<SoulNameDetails
[]>
login
▸ login(masa
): Promise
<undefined
| { address
: string
; cookie?
: string
; userId
: string
| BigNumber
}>
Parameters
Name | Type |
---|---|
masa | Masa |
Returns
Promise
<undefined
| { address
: string
; cookie?
: string
; userId
: string
| BigNumber
}>
logout
▸ logout(masa
): Promise
<undefined
| { status
: string
}>
Parameters
Name | Type |
---|---|
masa | Masa |
Returns
Promise
<undefined
| { status
: string
}>
patchMetadataUrl
▸ patchMetadataUrl(masa
, tokeUri
): string
Parameters
Name | Type |
---|---|
masa | Masa |
tokeUri | string |
Returns
string
printSoulName
▸ printSoulName(soulName
, index?
): void
Parameters
Name | Type |
---|---|
soulName | SoulNameDetails |
index? | number |
Returns
void
purchaseIdentity
▸ purchaseIdentity(masa
): Promise
<void
>
Parameters
Name | Type |
---|---|
masa | Masa |
Returns
Promise
<void
>
purchaseIdentityWithSoulName
▸ purchaseIdentityWithSoulName(masa
, soulName
, soulNameLength
, duration
, paymentMethod
): Promise
<void
>
Parameters
Name | Type |
---|---|
masa | Masa |
soulName | string |
soulNameLength | number |
duration | number |
paymentMethod | PaymentMethod |
Returns
Promise
<void
>
recoverAddress
▸ recoverAddress(msg
, signature
, doHash?
): undefined
| string
Parameters
Name | Type | Default value |
---|---|---|
msg | string | undefined |
signature | string | undefined |
doHash | boolean | false |
Returns
undefined
| string
sendSoulName
▸ sendSoulName(masa
, soulName
, receiver
): Promise
<void
>
Parameters
Name | Type |
---|---|
masa | Masa |
soulName | string |
receiver | string |
Returns
Promise
<void
>
sendSoulNameByName
▸ sendSoulNameByName(masa
, soulName
, receiver
): Promise
<void
>
Parameters
Name | Type |
---|---|
masa | Masa |
soulName | string |
receiver | string |
Returns
Promise
<void
>
showIdentity
▸ showIdentity(masa
, address?
): Promise
<undefined
| { metadata?
: IIdentity
; tokenId
: BigNumber
; tokenUri
: string
}>
Parameters
Name | Type |
---|---|
masa | Masa |
address? | string |
Returns
Promise
<undefined
| { metadata?
: IIdentity
; tokenId
: BigNumber
; tokenUri
: string
}>
signMessage
▸ signMessage(msg
, wallet
, doHash?
): Promise
<undefined
| string
>
Parameters
Name | Type | Default value |
---|---|---|
msg | string | undefined |
wallet | Signer | Wallet | undefined |
doHash | boolean | false |
Returns
Promise
<undefined
| string
>
signSoulLinkerLink
▸ signSoulLinkerLink(masa
, readerIdentityId
, ownerIdentityId
, tokenAddress
, tokenId
, signatureDate?
, expirationOffset?
): Promise
<{ expirationDate
: number
; signature
: string
; signatureDate
: number
}>
Parameters
Name | Type |
---|---|
masa | Masa |
readerIdentityId | BigNumber |
ownerIdentityId | BigNumber |
tokenAddress | string |
tokenId | BigNumber |
signatureDate | number |
expirationOffset | number |
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
Name | Type |
---|---|
contract | Contract |
wallet | Wallet |
name | string |
types | Record <string , TypedDataField []> |
value | Record <string , any > |
Returns
Promise
<{ domain
: { chainId
: number
; name
: string
; verifyingContract
: string
; version
: string
= "1.0.0" } ; signature
: string
}>
unpackSessionId
▸ unpackSessionId(cookie?
): undefined
| string
Parameters
Name | Type |
---|---|
cookie? | string |
Returns
undefined
| string
validateSoulName
▸ validateSoulName(masa
, soulName
): Object
Parameters
Name | Type |
---|---|
masa | Masa |
soulName | string |
Returns
Object
Name | Type |
---|---|
isValid | boolean |
length | number |
message? | string |
verifyLink
▸ verifyLink(masa
, contract
, tokenId
, readerIdentityId?
): Promise
<VerifyLinkResult
>
Parameters
Name | Type |
---|---|
masa | Masa |
contract | Contract |
tokenId | BigNumber |
readerIdentityId? | BigNumber |
Returns
Promise
<VerifyLinkResult
>
version
▸ version(): Object
Returns
Object
Name | Type |
---|---|
contractsVersion | string |
sdkVersion | string |