Depositing NEAR for Storage
Overview
When depositing NEAR to the social DB contract, you can cover the storage cost for a specific account_id or the signer if account_id is not provided. You can also choose to pay the bare minimum deposit required for registering the account in the Social DB contract without any additional storage fees.
The signer account MUST have sufficient NEAR balance to cover the deposit.
- JavaScript (via package manager)
- JavaScript (via CDN)
- TypeScript
const { Social } = require('@builddao/near-social-js');
const social = new Social();
const transaction = await social.storageDeposit({
account: {
accountID: 'alice.near',
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
},
registration_only: true, // set to true if you want to pay only the bare minimum deposit
account_id: 'bob.near', // optional, defaults to the signer account
deposit: '10000000000000000000000', // the amount to deposit in yoctoNEAR
});
// ...sign the returned transaction and post to the network
var social = new NEARSocialSDK();
social.storageDeposit({
account: {
accountID: 'alice.near',
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
},
account_id: 'bob.near', // optional, defaults to the signer account
deposit: '10000000000000000000000', // the amount to deposit in yoctoNEAR
registration_only: true // set to true if you want to pay only the bare minimum deposit
})
.then((transaction) => {
// ...sign the returned transaction and post to the network
});
import { Social } from '@builddao/near-social-js';
const social = new Social();
const transaction = await social.storageDeposit({
account: {
accountID: 'alice.near',
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
},
account_id: 'bob.near', // optional, defaults to the signer account
deposit: '10000000000000000000000', // the amount to deposit in yoctoNEAR
registration_only: true, // set to true if you want to pay only the bare minimum deposit
});
// ...sign the returned transaction and post to the network
Withdrawing NEAR from Storage
Overview
When withdrawing NEAR from the social DB contract, you can specify the amount to withdraw. If no amount is specified, all available NEAR is withdrawn.
The signer account MUST have sufficient NEAR balance available for withdrawal.
- JavaScript (via package manager)
- JavaScript (via CDN)
- TypeScript
const { Social } = require('@builddao/near-social-js');
const social = new Social();
const transaction = await social.storageWithdraw({
account: {
accountID: 'alice.near',
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
},
amount: '5000000000000000000000', // the amount to withdraw in yoctoNEAR, optional, defaults to all available balance
});
// ...sign the returned transaction and post to the network
var social = new NEARSocialSDK();
social.storageWithdraw({
account: {
accountID: 'alice.near',
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
},
amount: '5000000000000000000000' // the amount to withdraw in yoctoNEAR, optional, defaults to all available balance
})
.then((transaction) => {
// ...sign the returned transaction and post to the network
});
import { Social } from '@builddao/near-social-js';
const social = new Social();
const transaction = await social.storageWithdraw({
account: {
accountID: 'alice.near',
publicKey: 'ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW',
},
amount: '5000000000000000000000', // the amount to withdraw in yoctoNEAR, optional, defaults to all available balance
});
// ...sign the returned transaction and post to the network