Skip to main content

Granting Write Permission

Overview

Accounts can grant write permission to other accounts for a set of keys.

Terminology

  • Grantee: The account that is being granted write access to the list of keys.
  • Granter: The account that will grant access to the list of keys.

Granting an account write permission

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

const social = new Social();
const transaction = await social.grantWritePermission({
account: {
accountID: 'bob.near',
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
},
granteeAccountId: 'alice.near',
keys: [
'alice.near/profile/name',
'alice.near/profile/image/url',
],
});

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

If the grantee account ID or the account ID in each key is not a valid account ID then a InvalidAccountIdError is thrown.

caution

If a key does is not owned by the granter, then a KeyNotAllowedError is thrown.