Skip to content

permaweb/ao-profile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@permaweb/aoprofile

This SDK provides a set of functions to interact with profile processes on AO. Profiles are a digital representation of entities, such as users, organizations, or channels. These processes include specific metadata that describes the entity and can be associated with various digital assets and collections. Profiles are created, updated, and fetched using the following functions.

Prerequisites

  • node >= v18.0
  • npm or yarn
  • @permaweb/aoconnect

Installation

npm install @permaweb/aoprofile

or

yarn add @permaweb/aoprofile

Initialization

import { connect, createDataItemSigner } from '@permaweb/aoconnect';
import { initAOProfile } from '@permaweb/aoprofile';

const ao = connect();
const signer = createDataItemSigner(window.arweaveWallet);

const { createProfile, updateProfile, getProfileById, getProfileByWalletAddress, getRegistryProfiles } = init({
	ao,
	signer,
	logging: true,
});

Usage

createProfile

Creates a profile, initializing a zone with specific profile relevant metadata. Note: using data urls for images will not work in NodeJS they will only work in a browser.

const profileId = await createProfile({
	userName: 'Sample username',
	displayName: 'Sample display name',
	description: 'Sample description',
	thumbnail: 'Profile image data (can be a browser data url like data: or an Arweave txid)',
	banner: 'Cover image data (can be a browser data url like data: or an Arweave txid)',
});
Parameters
  • args: Object containing profile details, including username, displayName, description, thumbnail, and banner
Response
string | null; // Profile ID or null if creation fails

updateProfile

Updates a profile by modifying its metadata, such as username, displayName, description, and optional image fields like thumbnail and banner.

const profileUpdateId = await updateProfile({
	profileId: profileId,
	userName: 'Sample Zone',
	displayName: 'Sample Zone',
	description: 'Sample description (can be a browser data url like data: or an Arweave txid)',
	thumbnail: 'Profile image data (can be a browser data url like data: or an Arweave txid)',
	banner: 'Cover image data',
});
Parameters
  • args: The correspending Profile ID, as well as the details to update, structured similarly to createProfile
Response
string | null; // Profile update ID or null if update fails

getProfileById

Fetches a profile based on its ID. Returns a structured profile object containing the profile’s metadata, assets, and other properties associated with the profile.

const profile = await getProfileById({ profileId });
Parameters
  • args: Object containing the ID to fetch specified by profileId
Response
{
  id: "ProfileProcessId",
  walletAddress: "WalletAddress",
	displayName: "Sample display name",
  username: "Sample username",
  description: "Sample description",
  thumbnail: "ThumbnailTxId",
  banner: "BannerTxId",
  assets: [
    "AssetProcessId1",
    "AssetProcessId2",
    "AssetProcessId3",
  ]
}

getProfileByWalletAddress

Fetches a profile using the wallet address associated with it. This function is useful for retrieving a profile when only the wallet address is known.

const profile = await getProfileByWalletAddress({ address: walletAddress });
Parameters
  • args: Object containing the wallet address to fetch specified by address
Response
{
  id: "ProfileProcessId",
  walletAddress: "WalletAddress",
	displayName: "Sample display name",
  username: "Sample username",
  description: "Sample description",
  thumbnail: "ThumbnailTxId",
  banner: "BannerTxId",
  assets: [
    "AssetProcessId1",
    "AssetProcessId2",
    "AssetProcessId3",
  ]
}

getRegistryProfiles

This function queries a profile registry process that contains information on all spawned AO profiles.

const profiles = await getRegistryProfiles({ profileIds: [ids] });
Parameters
  • args: Object containing the ids to fetch specified by profileIds
Response
[
  {
    id: 'ProfileProcessId',
    username: 'Sample username',
    thumbnail: 'ThumbnailTxId',
    description: 'Sample description',
    lastUpdate: '1736293783295'
  }
]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •