getPortrait()
The getPortrait()
function is used to get a user's or collective's Portrait object, which contains the user's or collective's Portrait data. The portraitObject
is fetched from IPFS and Arweave concurrently to ensure the quickest resolving possible.
Syntax
Parameters
identity
- A required parameter of typeIdentity
.Identity
is of type:UserPortraitAddress
- Ethereum addressUserPortraitENSName
- ENS nameCollectivePortraitName
- Collective Portrait Name (a-z, 0-9, min. 3 chars, max. 64 chars.)
Return Value
This function returns a
Promise
that resolves with aPortraitObject
if the user or collective has a Portrait. If the user or collective does not have a Portrait, the function returns aPromise
that resolves withnull
.
Usage
This function is useful in situations where you need to retrieve the Portrait data for a given user or collective. The function takes an identity as input, which can be either an Ethereum address, an ENS name, or a Collective Portrait name. The function determines the type of the input identity and retrieves the Portrait object accordingly.
The function uses the getPortraitHash()
method internally to retrieve the hash of the user's or collective's Portrait. Once the hash is retrieved, the function calls the fetchPortrait()
function to retrieve the Portrait object from IPFS.
Example
In this example, the getPortrait()
function is used to retrieve the Portrait object for the given ENS name. If the user has a Portrait, the function logs the Portrait object to the console. If the user does not have a Portrait, the function logs a message indicating that the user does not have a Portrait.
Last updated