Skip to main content

Storing Data

Overview

When storing data, the top-level property must match an account ID. All the nested objects/properties will then be stored under this account.

note

The signer account MUST have write permissions granted for the account to which it wants to write. See granting permissions on how to grant write permissions.

note

The signer account automatically has write permissions for their own account.

Storing data for an account

const { Social } = require('@builddao/near-social-js');

const social = new Social();
const transaction = await social.set({
account: {
accountID: 'alice.near',
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
},
data: {
['alice.near']: {
profile: {
name: 'Alice',
},
},
},
});

// ...sign the returned transaction and post to the network