Getting Started

Follow these simple steps to register GeoDIDs quickly

Setting up local Powergate Client

In order to store the GeoDIDs created by the core package, you will need to start up a local Powergate client or connect to an existing hosted client. Below will be a brief overview on how to setup a local Powergate client on your system. Further information is available at:
In order to setup the Powergate Client locally on your system you must have Docker, Docker-Compose, and Go 1.16 installed.
In your terminal, create a new directory and clone the Powergate repo into it:
git clone
After you clone the repo, enter the following commands:
cd powergate/docker
make localnet
More information regarding Powergate's Localnet mode, please refer to their documentation:

Install the packages

yarn add @astralprotocol/core @astralprotocol/contracts dotenv bs58 truffle @truffle/hdwallet-provider

Configure truffle-config.js

const HDWalletProvider = require("@truffle/hdwallet-provider");
// Create a .env file with your MNEMONIC and a ROPSTEN API key from INFURA
// Must have the following format:
// MNEMONIC="words here "
let mnemonic = process.env.MNEMONIC
let ropstenURL = process.env.ROPSTEN_API_KEY
let provider = new HDWalletProvider({
mnemonic: {
phrase: mnemonic,
providerOrUrl: ropstenURL,
module.exports = {
networks: {
development: {
host: "",
port: 8545,
network_id: "*",
ropsten: {
provider: provider,
network_id: "3",
compilers: {
solc: {
version: "0.6.12",

Create a script for interacting with the Astral Client and Contracts

const { AstralClient } = require('@astralprotocol/core');
const SpatialAssets = require("@astralprotocol/contracts/build/contracts/SpatialAssets.json")
const bs58 = require('bs58')
module.exports = async function (callback) {
const stringToBytes = (string) => web3.utils.asciiToHex(string)
// based on
// Return bytes32 hex string from base58 encoded ipfs hash,
// stripping leading 2 bytes from 34 byte IPFS hash
// Assume IPFS defaults: function:0x12=sha2, size:0x20=256 bits
// E.g. "QmNSUYVKDSvPUnRLKmuxk9diJ6yS96r1TrAXzjTiBcCLAL" -->
// "0x017dfd85d4f6cb4dcd715a88101f7b1f06cd1e009b2327a0809d01eb9c91f231"
function getBytes32FromIpfsHash(ipfsListing) {
return "0x"+bs58.decode(ipfsListing).slice(2).toString('hex')
try {
const accounts = await web3.eth.getAccounts()
const userAccount = accounts[0]
// find contract in network 3 (Ropsten)
const SpatialAssetsContract = new web3.eth.Contract(SpatialAssets.abi, SpatialAssets.networks['3'].address, {
from: userAccount,
data: SpatialAssets.deployedBytecode,
// update the endpoint to the latest
const subgraphEndpoint = ""
const astral = await, subgraphEndpoint, "");
const storage = stringToBytes('FILECOIN');
// Creates a Genesis GeoDID
const genDocRes = await astral.createGenesisGeoDID('collection')
// With the returned IDocumentInfo from the last function, we can pin it.
// Since no token was specified the client will assign a new auth Token to the user.
const results = await astral.pinDocument(genDocRes);
// register the geodid id and cid obtained. Type 0 because it is a collection
const bytes32GeoDID= getBytes32FromIpfsHash(results.geodidid.substring(8));
const bytes32Cid = getBytes32FromIpfsHash(results.cid);
try {
await SpatialAssetsContract.methods.registerSpatialAsset(userAccount, bytes32GeoDID, stringToBytes(''),[], bytes32Cid, storage,0).send()
.on('receipt', function(receipt){
// receipt example
.on('error', function(error) { // If the transaction was rejected by the network with a receipt, the second parameter will be the receipt.
catch (err) {
// Will throw an error if tx reverts
// With the Auth Token and the GeoDID ID we can load the document with the loadDocument function
const loadResults = await astral.loadDocument(results.geodidid);
catch(error) {
"deployGeoDIDs": "truffle exec scripts/deployGeoDIDs.js --network ropsten",

And execute with

yarn deployGeoDIDs
The steps executed in this page have been reproduced in a public github that you can consult: ****