Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- OrgId
- Optimization enabled
- true
- Compiler version
- v0.8.17+commit.8df45f5f
- Optimization runs
- 200
- EVM Version
- london
- Verified at
- 2022-11-25T12:50:58.447631Z
contracts/OrgId.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
import './OrgIdInterface.sol';
import '@openzeppelin/contracts/utils/math/SafeMath.sol';
/**
* @title ORGiD Registry Smart Contract
*/
contract OrgId is OrgIdInterface {
using SafeMath for uint256;
/// @dev Organization structure
struct Organization {
bytes32 orgId;
bytes32 orgJsonHash;
string orgJsonUri;
string orgJsonUriBackup1;
string orgJsonUriBackup2;
bytes32 parentOrgId;
address owner;
address director;
bool isActive;
bool isDirectorshipAccepted;
bytes32[] units;
}
/// @dev Mapped list of Organizations
mapping(bytes32 => Organization) internal organizations;
bytes32[] public orgIds;
function createOrgIdFor(
bytes32 orgId,
bytes32 parentOrgId,
address owner,
string calldata orgJsonUri,
bytes32 orgJsonHash
) external override {
require(organizations[orgId].orgId == bytes32(0), 'OrgId: ORGiD already exists');
require(bytes(orgJsonUri).length != 0, 'OrgId: orgJsonUri cannot be empty');
organizations[orgId] = Organization(
orgId,
orgJsonHash,
orgJsonUri,
'',
'',
parentOrgId,
owner,
owner,
true,
true,
new bytes32[](0)
);
orgIds.push(orgId);
if (parentOrgId != bytes32(0)) {
organizations[parentOrgId].units.push(orgId);
}
}
function getOrganization(
bytes32 _orgId
)
external
view
override
returns (
bool exists,
bytes32 orgId,
bytes32 orgJsonHash,
string memory orgJsonUri,
string memory orgJsonUriBackup1,
string memory orgJsonUriBackup2,
bytes32 parentOrgId,
address owner,
address director,
bool isActive,
bool isDirectorshipAccepted
)
{
exists = _orgId != bytes32(0) && organizations[_orgId].orgId == _orgId;
orgId = organizations[_orgId].orgId;
orgJsonHash = organizations[_orgId].orgJsonHash;
orgJsonUri = organizations[_orgId].orgJsonUri;
orgJsonUriBackup1 = organizations[_orgId].orgJsonUriBackup1;
orgJsonUriBackup2 = organizations[_orgId].orgJsonUriBackup2;
parentOrgId = organizations[_orgId].parentOrgId;
owner = organizations[_orgId].owner;
director = organizations[_orgId].director;
isActive = organizations[_orgId].isActive;
isDirectorshipAccepted = organizations[_orgId].isDirectorshipAccepted;
}
function getOrganizations(bool __)
external
view
override
returns (bytes32[] memory)
{
return orgIds;
}
function getUnits(bytes32 parentOrgId, bool __)
external
view
override
returns (bytes32[] memory)
{
return organizations[parentOrgId].units;
}
}
/contracts/OrgIdInterface.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
/**
* @title Test ORGiD Smart Contract Interface
*/
abstract contract OrgIdInterface {
function createOrgIdFor(
bytes32 orgId,
bytes32 parentOrgId,
address owner,
string calldata orgJsonUri,
bytes32 orgJsonHash
) external virtual;
function getOrganization(
bytes32 _orgId
)
external
view
virtual
returns (
bool exists,
bytes32 orgId,
bytes32 orgJsonHash,
string memory orgJsonUri,
string memory orgJsonUriBackup1,
string memory orgJsonUriBackup2,
bytes32 parentOrgId,
address owner,
address director,
bool isActive,
bool isDirectorshipAccepted
);
function getOrganizations(bool __) external view virtual returns (bytes32[] memory);
function getUnits(bytes32 parentOrgId, bool includeInactive)
external
view
virtual
returns (bytes32[] memory);
}
/_openzeppelin/contracts/utils/math/SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
Contract ABI
[{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"createOrgIdFor","inputs":[{"type":"bytes32","name":"orgId","internalType":"bytes32"},{"type":"bytes32","name":"parentOrgId","internalType":"bytes32"},{"type":"address","name":"owner","internalType":"address"},{"type":"string","name":"orgJsonUri","internalType":"string"},{"type":"bytes32","name":"orgJsonHash","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"exists","internalType":"bool"},{"type":"bytes32","name":"orgId","internalType":"bytes32"},{"type":"bytes32","name":"orgJsonHash","internalType":"bytes32"},{"type":"string","name":"orgJsonUri","internalType":"string"},{"type":"string","name":"orgJsonUriBackup1","internalType":"string"},{"type":"string","name":"orgJsonUriBackup2","internalType":"string"},{"type":"bytes32","name":"parentOrgId","internalType":"bytes32"},{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"director","internalType":"address"},{"type":"bool","name":"isActive","internalType":"bool"},{"type":"bool","name":"isDirectorshipAccepted","internalType":"bool"}],"name":"getOrganization","inputs":[{"type":"bytes32","name":"_orgId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32[]","name":"","internalType":"bytes32[]"}],"name":"getOrganizations","inputs":[{"type":"bool","name":"__","internalType":"bool"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32[]","name":"","internalType":"bytes32[]"}],"name":"getUnits","inputs":[{"type":"bytes32","name":"parentOrgId","internalType":"bytes32"},{"type":"bool","name":"__","internalType":"bool"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"orgIds","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b50610b42806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80630c70d7c51461005c5780630dd56c931461008557806322b3cd4e146100985780639558f9ec146100c2578063e8e87441146100e3575b600080fd5b61006f61006a366004610783565b6100f8565b60405161007c91906107a5565b60405180910390f35b61006f6100933660046107e9565b610152565b6100ab6100a6366004610815565b6101b6565b60405161007c9b9a99989796959493929190610874565b6100d56100d0366004610815565b610427565b60405190815260200161007c565b6100f66100f1366004610904565b610448565b005b6060600180548060200260200160405190810160405280929190818152602001828054801561014657602002820191906000526020600020905b815481526020019060010190808311610132575b50505050509050919050565b600082815260208181526040918290206008018054835181840281018401909452808452606093928301828280156101a957602002820191906000526020600020905b815481526020019060010190808311610195575b5050505050905092915050565b600080806060808083808080808b158015906101df575060008c8152602081905260409020548c145b60008d81526020819052604090208054600182015460029092018054939e50909c50909a509061020e906109b1565b80601f016020809104026020016040519081016040528092919081815260200182805461023a906109b1565b80156102875780601f1061025c57610100808354040283529160200191610287565b820191906000526020600020905b81548152906001019060200180831161026a57829003601f168201915b505050505097506000808d815260200190815260200160002060030180546102ae906109b1565b80601f01602080910402602001604051908101604052809291908181526020018280546102da906109b1565b80156103275780601f106102fc57610100808354040283529160200191610327565b820191906000526020600020905b81548152906001019060200180831161030a57829003601f168201915b505050505096506000808d8152602001908152602001600020600401805461034e906109b1565b80601f016020809104026020016040519081016040528092919081815260200182805461037a906109b1565b80156103c75780601f1061039c576101008083540402835291602001916103c7565b820191906000526020600020905b8154815290600101906020018083116103aa57829003601f168201915b50505060009e8f52505060208d90526040909c20600581015460068201546007909201549c9e9b9d9a9c999b989a9990986001600160a01b039283169850918116965060ff600160a01b820481169650600160a81b909104169350915050565b6001818154811061043757600080fd5b600091825260209091200154905081565b600086815260208190526040902054156104a95760405162461bcd60e51b815260206004820152601b60248201527f4f726749643a204f5247694420616c726561647920657869737473000000000060448201526064015b60405180910390fd5b60008290036105045760405162461bcd60e51b815260206004820152602160248201527f4f726749643a206f72674a736f6e5572692063616e6e6f7420626520656d70746044820152607960f81b60648201526084016104a0565b60405180610160016040528087815260200182815260200184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525093855250506040805160208082018352848252808601919091528151808201835284815282860152606085018b90526001600160a01b038a166080860181905260a0860152600160c0860181905260e0860181905282518581528083018452610100909601959095528b845283815292819020855181559285015193830193909355509082015160028201906105e49082610a4c565b50606082015160038201906105f99082610a4c565b506080820151600482019061060e9082610a4c565b5060a0820151600582015560c08201516006820180546001600160a01b0319166001600160a01b0392831617905560e0830151600783018054610100860151610120870151939094166001600160a81b031990911617600160a01b931515939093029290921760ff60a81b1916600160a81b9115159190910217905561014082015180516106a691600884019160209091019061070e565b50506001805480820182556000919091527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf60187905550841561070657600085815260208181526040822060080180546001810182559083529120018690555b505050505050565b828054828255906000526020600020908101928215610749579160200282015b8281111561074957825182559160200191906001019061072e565b50610755929150610759565b5090565b5b80821115610755576000815560010161075a565b8035801515811461077e57600080fd5b919050565b60006020828403121561079557600080fd5b61079e8261076e565b9392505050565b6020808252825182820181905260009190848201906040850190845b818110156107dd578351835292840192918401916001016107c1565b50909695505050505050565b600080604083850312156107fc57600080fd5b8235915061080c6020840161076e565b90509250929050565b60006020828403121561082757600080fd5b5035919050565b6000815180845260005b8181101561085457602081850181015186830182015201610838565b506000602082860101526020601f19601f83011685010191505092915050565b60006101608d151583528c60208401528b604084015280606084015261089c8184018c61082e565b905082810360808401526108b0818b61082e565b905082810360a08401526108c4818a61082e565b60c084019890985250506001600160a01b0394851660e0820152929093166101008301521515610120820152901515610140909101529695505050505050565b60008060008060008060a0878903121561091d57600080fd5b863595506020870135945060408701356001600160a01b038116811461094257600080fd5b9350606087013567ffffffffffffffff8082111561095f57600080fd5b818901915089601f83011261097357600080fd5b81358181111561098257600080fd5b8a602082850101111561099457600080fd5b602083019550809450505050608087013590509295509295509295565b600181811c908216806109c557607f821691505b6020821081036109e557634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b601f821115610a4757600081815260208120601f850160051c81016020861015610a285750805b601f850160051c820191505b8181101561070657828155600101610a34565b505050565b815167ffffffffffffffff811115610a6657610a666109eb565b610a7a81610a7484546109b1565b84610a01565b602080601f831160018114610aaf5760008415610a975750858301515b600019600386901b1c1916600185901b178555610706565b600085815260208120601f198616915b82811015610ade57888601518255948401946001909101908401610abf565b5085821015610afc5787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fea2646970667358221220f1cec3413baf4908015f376f5093477897012cb343892a41605b97102ad9da5e64736f6c63430008110033
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100575760003560e01c80630c70d7c51461005c5780630dd56c931461008557806322b3cd4e146100985780639558f9ec146100c2578063e8e87441146100e3575b600080fd5b61006f61006a366004610783565b6100f8565b60405161007c91906107a5565b60405180910390f35b61006f6100933660046107e9565b610152565b6100ab6100a6366004610815565b6101b6565b60405161007c9b9a99989796959493929190610874565b6100d56100d0366004610815565b610427565b60405190815260200161007c565b6100f66100f1366004610904565b610448565b005b6060600180548060200260200160405190810160405280929190818152602001828054801561014657602002820191906000526020600020905b815481526020019060010190808311610132575b50505050509050919050565b600082815260208181526040918290206008018054835181840281018401909452808452606093928301828280156101a957602002820191906000526020600020905b815481526020019060010190808311610195575b5050505050905092915050565b600080806060808083808080808b158015906101df575060008c8152602081905260409020548c145b60008d81526020819052604090208054600182015460029092018054939e50909c50909a509061020e906109b1565b80601f016020809104026020016040519081016040528092919081815260200182805461023a906109b1565b80156102875780601f1061025c57610100808354040283529160200191610287565b820191906000526020600020905b81548152906001019060200180831161026a57829003601f168201915b505050505097506000808d815260200190815260200160002060030180546102ae906109b1565b80601f01602080910402602001604051908101604052809291908181526020018280546102da906109b1565b80156103275780601f106102fc57610100808354040283529160200191610327565b820191906000526020600020905b81548152906001019060200180831161030a57829003601f168201915b505050505096506000808d8152602001908152602001600020600401805461034e906109b1565b80601f016020809104026020016040519081016040528092919081815260200182805461037a906109b1565b80156103c75780601f1061039c576101008083540402835291602001916103c7565b820191906000526020600020905b8154815290600101906020018083116103aa57829003601f168201915b50505060009e8f52505060208d90526040909c20600581015460068201546007909201549c9e9b9d9a9c999b989a9990986001600160a01b039283169850918116965060ff600160a01b820481169650600160a81b909104169350915050565b6001818154811061043757600080fd5b600091825260209091200154905081565b600086815260208190526040902054156104a95760405162461bcd60e51b815260206004820152601b60248201527f4f726749643a204f5247694420616c726561647920657869737473000000000060448201526064015b60405180910390fd5b60008290036105045760405162461bcd60e51b815260206004820152602160248201527f4f726749643a206f72674a736f6e5572692063616e6e6f7420626520656d70746044820152607960f81b60648201526084016104a0565b60405180610160016040528087815260200182815260200184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525093855250506040805160208082018352848252808601919091528151808201835284815282860152606085018b90526001600160a01b038a166080860181905260a0860152600160c0860181905260e0860181905282518581528083018452610100909601959095528b845283815292819020855181559285015193830193909355509082015160028201906105e49082610a4c565b50606082015160038201906105f99082610a4c565b506080820151600482019061060e9082610a4c565b5060a0820151600582015560c08201516006820180546001600160a01b0319166001600160a01b0392831617905560e0830151600783018054610100860151610120870151939094166001600160a81b031990911617600160a01b931515939093029290921760ff60a81b1916600160a81b9115159190910217905561014082015180516106a691600884019160209091019061070e565b50506001805480820182556000919091527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf60187905550841561070657600085815260208181526040822060080180546001810182559083529120018690555b505050505050565b828054828255906000526020600020908101928215610749579160200282015b8281111561074957825182559160200191906001019061072e565b50610755929150610759565b5090565b5b80821115610755576000815560010161075a565b8035801515811461077e57600080fd5b919050565b60006020828403121561079557600080fd5b61079e8261076e565b9392505050565b6020808252825182820181905260009190848201906040850190845b818110156107dd578351835292840192918401916001016107c1565b50909695505050505050565b600080604083850312156107fc57600080fd5b8235915061080c6020840161076e565b90509250929050565b60006020828403121561082757600080fd5b5035919050565b6000815180845260005b8181101561085457602081850181015186830182015201610838565b506000602082860101526020601f19601f83011685010191505092915050565b60006101608d151583528c60208401528b604084015280606084015261089c8184018c61082e565b905082810360808401526108b0818b61082e565b905082810360a08401526108c4818a61082e565b60c084019890985250506001600160a01b0394851660e0820152929093166101008301521515610120820152901515610140909101529695505050505050565b60008060008060008060a0878903121561091d57600080fd5b863595506020870135945060408701356001600160a01b038116811461094257600080fd5b9350606087013567ffffffffffffffff8082111561095f57600080fd5b818901915089601f83011261097357600080fd5b81358181111561098257600080fd5b8a602082850101111561099457600080fd5b602083019550809450505050608087013590509295509295509295565b600181811c908216806109c557607f821691505b6020821081036109e557634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b601f821115610a4757600081815260208120601f850160051c81016020861015610a285750805b601f850160051c820191505b8181101561070657828155600101610a34565b505050565b815167ffffffffffffffff811115610a6657610a666109eb565b610a7a81610a7484546109b1565b84610a01565b602080601f831160018114610aaf5760008415610a975750858301515b600019600386901b1c1916600185901b178555610706565b600085815260208120601f198616915b82811015610ade57888601518255948401946001909101908401610abf565b5085821015610afc5787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fea2646970667358221220f1cec3413baf4908015f376f5093477897012cb343892a41605b97102ad9da5e64736f6c63430008110033