Skip to main content

SocialDB

SocialDB is a smart contract to store social data on NEAR protocol.

Get APIโ€‹

Takes a list of keys and returns a joined JSON object with the matched data.

pub fn get(self, keys: Vec<String>) -> Value;
  • keys - an array of key patterns to return.

Returns the aggregated JSON object.

Reading a profile of account self.social.nearโ€‹

To read all fields recursively for a given path add ** suffix.

env NEAR_ENV=mainnet near view social.near get '{"keys":["self.social.near/profile/**"]}'
{
"self.social.near": {
"profile": {
"name": "Near Social",
"image": {
"ipfs_cid": "bafkreiej5new6k7bzlaaapuc7fgjlwaoqqw2qgzvilbmdankmfxw7siw6q"
},
"linktree": {
"twitter": "NearSocial_",
"github": "NearSocial",
"telegram": "NearSocial",
"website": "near.social"
}
}
}
}
Reading names of all account with profilesโ€‹

Note that this query iterates over all accounts and will not fit into the available view call gas in the future.

env NEAR_ENV=mainnet near view social.near get '{"keys":["*/profile/name"]}'
{
"mob.near": {
"profile": {
"name": "Eugene The Dream"
}
},
"nearcondemo.near": {
"profile": {
"name": "Very Berry Demo Acc"
}
},
"zavodil.near": {
"profile": {
"name": "Vadim"
}
},

................................

"kuzu.near": {
"profile": {
"name": "Joinairdrops"
}
},
"goldich.near": {
"profile": {
"name": "MAG"
}
}
}

Keys APIโ€‹

Takes a list of keys and returns a joined JSON object with the keys matched the query.

pub fn keys(self, keys: Vec<String>) -> Value;
  • keys - an array of key patterns to return.

Returns the aggregated JSON object.

Getting a list of components of accounts root.nearโ€‹
env NEAR_ENV=mainnet near view social.near keys '{"keys":["root.near/widget/*"]}'
{
"root.near": {
"widget": {
"AllProfilesWithGithub": true,
"Egg": true,
"TotalAccountsCount": true
}
}
}
Getting a list of accounts that have componentsโ€‹
env NEAR_ENV=mainnet near view social.near keys '{"keys":["*/widget"]}'

Note that this query iterates over all accounts and will not fit into the available view call gas in the future.

{
"mob.near": {
"widget": true
},
"nearcondemo.near": {
"widget": true
},
"zavodil.near": {
"widget": true
},

................................

"elektromania.near": {
"widget": true
},
"kn00t.near": {
"widget": true
}
}