OrgId is the core smart contract of the ORGiD protocol. It is a decentralized registry of unique identifiers used for the creation and managing of network-specific DIDs'. The main idea of the ORGiD protocol is providing of the providing a Self Sovereign Identity (SSI) for every organization or person.
The ORGiD smart contract supports ERC721 interface, so every entity represented by the unique Id is recognizable as NFT.
Every identifier is represented by the following metadata:
tokenId- NFT Id, a unique entity index, integer number which enumeration starts from the
orgId- unique organization hash;
owner- an entity owner, the Ethereum address that has exceptional right to manage metadata changes and transfer ownership of the identifier;
orgJsonUri- HTTP or IPFS/IPNS link to an off-chain JSON file with data related to identifier composed in accordance to ORG.JSON schema.
ORGiD contract metadata (ERC721)
name- NFT name is
symbol- NFT symbol is
tokenURI- link to a NFT metadata, the same as
ORGiD contract core features
createOrgId(bytes32,string) is allowing to create an unique identifier in predictable way.
The identifier is generating as a keccak256 hash of Ethereum address of the function caller and of a unique bytes32 hash salt that generated (off-chain).
The function caller is able to reproduce the generation algorithm off-chain before the function will be called.
orgId creation, also the
tokenId is assigning that is the next-available token Id in the storage. These two unique identifiers are cross-referenced in the contract storage.
orgJsonUriparameter cannot be empty string;
saltparameter cannot be used twice by the same function caller.
Identifiers can be looked up by these functions:
getOrgIds()getting of the complete list of all registered
getOrgIds(uint256,uint256)getting of paginated list of
getTokenId(bytes32)getting of the
getOrgId(uint256)getting of the whole metadata set by given
The ORGiD metadata set that returns
getOrgId(uint256) consists of:
existsboolean flag (helper) of an
orgIdunique organization hash
orgJsonUrilink to off-chain JSON data file
owneran owner Ethereum address
setOrgJson(bytes32,string) allows to change a value of the
orgJsonUri linked to the
orgJsonmust not be empty string
- Function must be called by the ORGiD owner
An ownership management in the smart contract is represented by the set functions that is a part of the ERC721 interface that imported from the OpenZeppelins' implementation.
approve(address,uint256)gives permission to
tokenIdtoken to another account
getApproved(uint256)returns the account approved for
setApprovalForAll(address,bool)approve or remove
operatoras an operator for the caller.
isApprovedForAll(address,address)Returns if the
operatoris allowed to manage all of the assets of
to, checking first that contract recipients are aware of the ERC721 protocol to prevent tokens from being forever locked.
Supported interfaces (ERC165)
ORGiD is ERC165 compatible smart contract that supports the following interfaces that can be verified by calling the
- ERC165 interface:
- ORGiD interface:
- ERC721Metadata interface:
- ERC721 interface:
- ERC721Enumerable interface:
To run the code you will need to initialize the following environment variables:
NETWORK_RPC_URL=https://<NETWORK_NAME>.infura.io/v3/<YOUR_INFURA_PROJECT_ID> ACCOUNT_KEY=<PRIVATE_KEY_OF_THE_DEPLOYER_ACCOUNT> ETHERSCAN_KEY=<YOUR_ETHERSCAN_API_KEY>
It is highly recommended not to store environment variables in raw files. Instead of this, you can use our
senvCLI tool (package: @windingtree/secure-env-cli) that allowing to encrypt an environment file. To initialize environment using encrypted variables you will have to run the command
npx senv ./path/to/encrypted.senv "<COMMAND_OR_SCRIPT_TO_START>". The
senvCLI tool will prompt you for a password and then start the command or script in the initialized environment.
After each deployment, upgrade or transfer please commit the repository changes. This is required for the normal operation of the management scripts in future. The management scripts are saving information about the transactions sent and addresses of deployed contracts instances.
Contracts size information
Linting & Testing
yarn lint yarn test
It is required to compile contract before the deployment.
npx hardhat --network <NETWORK_NAME> deploy
npx senv ./<PATH_TO_ENCRYPTED>.senv "npx hardhat --network <NETWORK_NAME> deploy"
The contract instance as well as the address of the proxy contract deployed will be saved in the file:
The proxy admin ownership transfer
This operation will be required if you want to transfer an ability to make upgrades of a token to a multisig wallet or DAO.
npx hardhat --network <NETWORK_NAME> transfer --address <ACCOUNT_ADDRESS>
npx senv ./<PATH_TO_ENCRYPTED>.senv "npx hardhat --network <NETWORK_NAME> transfer --address <ACCOUNT_ADDRESS>"
npx hardhat --network <NETWORK_NAME> upgrade --name <NAME_OF_THE_NEW_CONTRACT> --proxy <PROXY_ADDRESS_TO_UPGRADE>
npx senv ./<PATH_TO_ENCRYPTED>.senv "npx hardhat --network <NETWORK_NAME> upgrade --name <NAME_OF_THE_NEW_CONTRACT> --proxy <PROXY_ADDRESS_TO_UPGRADE>"
Prepare an upgrade
This operation will be required if you want to just deploy a new instance. As result, you will get an address of the deployed contract instance which can be used in the multisig wallet or DAO for initialization of an upgrade.
npx hardhat --network <NETWORK_NAME> prepare --name <NAME_OF_THE_NEW_CONTRACT> --proxy <PROXY_ADDRESS_TO_UPGRADE>
npx senv ./<PATH_TO_ENCRYPTED>.senv "npx hardhat --network <NETWORK_NAME> prepare --name <NAME_OF_THE_NEW_CONTRACT> --proxy <PROXY_ADDRESS_TO_UPGRADE>"
A result will look like:
ORGiD instance deployed at: 0x8626f6940E2...F49B2d1F2C9C1199
npx senv ./<PATH_TO_ENCRYPTED>.senv "npx hardhat verify --network <NETWORK_NAME> <CONTRACT_ADDRESS_TO_VERIFY>"
Before testing you must setup an Optimism Ethereum node according to these guidelines
Currently, testing and deployment with Optimism is not supported because of OVM solidity compiler version limitations. We expecting that in the middle of Oct 2021 version 0.8.7 will be supported by OVM
yarn node:opt yarn test:opt
Before the deployment to the Optimism Mainnet the contract must be approved by the Optimism team via this form
The ORGiD contract is deployable to the Arbitrum Testnet and Mainnet in the same way as described for the Ethereum network with same compiler parameters.