Address Details
contract
0xCAccF1201b404c288ff2001a0C2d94b6cE63d144
- Contract Name
- CarbonCreditTokenFactory
- Creator
- 0x957e72–18f089 at 0x5a6264–7c93ce
- Balance
- 0 CELO ( )
- Locked CELO Balance
- 0.00 CELO
- Voting CELO Balance
- 0.00 CELO
- Pending Unlocked Gold
- 0.00 CELO
- Tokens
-
Fetching tokens...
- Transactions
- 0 Transactions
- Transfers
- 0 Transfers
- Gas Used
- Fetching gas used...
- Last Balance Update
- 10589404
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- CarbonCreditTokenFactory
- Optimization enabled
- true
- Compiler version
- v0.8.9+commit.e5eed63a
- Optimization runs
- 200
- EVM Version
- london
- Verified at
- 2022-05-06T22:18:25.340570Z
project:/contracts/CarbonCreditTokenFactory.sol
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.9; import '@openzeppelin/contracts-upgradeable/proxy/ClonesUpgradeable.sol'; import "./abstracts/AbstractTokenFactory.sol"; import './CarbonCreditToken.sol'; /// @author FlowCarbon LLC /// @title A Carbon Credit Token Factory contract CarbonCreditTokenFactory is AbstractTokenFactory { using ClonesUpgradeable for address; /// @param implementationContract_ the contract that is used a implementation base for new tokens constructor (CarbonCreditToken implementationContract_, address owner_) { swapImplementationContract(implementationContract_); transferOwnership(owner_); } /// @notice Deploy a new carbon credit token /// @param name_ the name of the new token, should be unique within the Flow Carbon Ecosystem /// @param symbol_ the token symbol of the ERC-20, should be unique within the Flow Carbon Ecosystem /// @param details_ token details to define the fungibillity characteristics of this token /// @param owner_ the owner of the new token (eligible to mint and finalize retirement) /// @return the address of the newly created token function createCarbonCreditToken( string memory name_, string memory symbol_, CarbonCreditToken.TokenDetails memory details_, address owner_) onlyOwner external returns (address) { CarbonCreditToken token = CarbonCreditToken(implementationContract.clone()); token.initialize(name_, symbol_, details_, owner_); finalizeCreation(address(token)); return address(token); } }
/_openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
/_openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
/_openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } uint256[49] private __gap; }
/_openzeppelin/contracts-upgradeable/proxy/ClonesUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for * deploying minimal proxy contracts, also known as "clones". * * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies * > a minimal bytecode implementation that delegates all calls to a known, fixed address. * * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2` * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the * deterministic method. * * _Available since v3.4._ */ library ClonesUpgradeable { /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create opcode, which should never revert. */ function clone(address implementation) internal returns (address instance) { assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create(0, ptr, 0x37) } require(instance != address(0), "ERC1167: create failed"); } /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create2 opcode and a `salt` to deterministically deploy * the clone. Using the same `implementation` and `salt` multiple time will revert, since * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) { assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create2(0, ptr, 0x37, salt) } require(instance != address(0), "ERC1167: create2 failed"); } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress( address implementation, bytes32 salt, address deployer ) internal pure returns (address predicted) { assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000) mstore(add(ptr, 0x38), shl(0x60, deployer)) mstore(add(ptr, 0x4c), salt) mstore(add(ptr, 0x6c), keccak256(ptr, 0x37)) predicted := keccak256(add(ptr, 0x37), 0x55) } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress(address implementation, bytes32 salt) internal view returns (address predicted) { return predictDeterministicAddress(implementation, salt, address(this)); } }
/_openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } }
/_openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./extensions/IERC20MetadataUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} uint256[45] private __gap; }
/_openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
/_openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
/_openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; }
/project_/contracts/CarbonCreditToken.sol
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.9; import "./abstracts/AbstractToken.sol"; /// @author FlowCarbon LLC /// @title A Carbon Credit Token Reference Implementation contract CarbonCreditToken is AbstractToken { struct TokenDetails { string methodology; string creditType; uint16 vintage; } TokenDetails private _details; /// @notice Emitted when the contract owner mints new tokens /// @dev the account is already in the Transfer Event and thus omitted here /// @param amount - the amount of token that finalize retirement /// @param checksum - a checksum associated with the underlying purchase event event Mint(uint256 amount, bytes32 checksum); /// @notice checksums associated with the underlying mapped to the number of minted tokens mapping (bytes32 => uint256) private _checksums; /// @notice checksums associated with the underlying retirement event mapped to the number of finally retired tokens mapping (bytes32 => uint256) private _retiredChecksums; /// @notice number of tokens removed from chain uint256 public movedOffChain; function initialize(string memory name_, string memory symbol_, TokenDetails memory details_, address owner_) external initializer { require(details_.vintage > 2000, 'Vintage out of bounds'); require(details_.vintage < 2100, 'Vintage out of bounds'); __AbstractToken_init(name_, symbol_, owner_); _details = details_; } /// @notice mints new tokens, a checksum representing purchase of the underlying with the minting event /// @param account_ - the account that will receive the new tokens /// @param amount_ - the amount of new tokens to be minted /// @param checksum_ - a checksum associated with the underlying purchase event function mint(address account_, uint256 amount_, bytes32 checksum_) external onlyOwner returns (bool) { require(_checksums[checksum_] == 0, "checksum was already used"); _mint(account_, amount_); _checksums[checksum_] = amount_; emit Mint(amount_, checksum_); return true; } /// @param checksum_ - the checksum associated with a minting event /// @return the amount minted with the associated checksum function amountMintedWithChecksum(bytes32 checksum_) external view returns (uint256) { return _checksums[checksum_]; } /// @notice the contract owner can finalize the retirement once the underlying has been retired /// @param amount_ the number of token to finalize retirement for /// @param checksum_ the checksum associated with the underlying retirement event function finalizeRetirement(uint256 amount_, bytes32 checksum_) external onlyOwner returns (bool) { require(_retiredChecksums[checksum_] == 0, "checksum was already used"); require(amount_ <= awaitingRetirement, "retire exceeds pending balance"); _retiredChecksums[checksum_] = amount_; awaitingRetirement -= amount_; retired += amount_; emit FinalizeRetirement(amount_, checksum_); return true; } /// @dev Destroys `amount` tokens from the caller. function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); if (owner() == _msgSender()) { movedOffChain += amount; } } /// @dev via ICarbonCreditTokenInterface function amountRetiredWithChecksum(bytes32 checksum_) external view returns (uint256) { return _retiredChecksums[checksum_]; } /// @notice The methodology of this token (e.g. verra or goldstandard) function methodology() external view returns (string memory) { return _details.methodology; } /// @notice The creditType of this token (e.g. enum like "WETLAND_RESTORATION", or "REFORESTATION") function creditType() external view returns(string memory) { return _details.creditType; } /// @notice The guaranteed vintage of this year - newer is possible because new is always better :-) function vintage() external view returns(uint16) { return _details.vintage; } }
/project_/contracts/abstracts/AbstractToken.sol
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import '@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol'; import "../interfaces/ICarbonCreditTokenInterface.sol"; /// @author FlowCarbon LLC /// @title An Abstract Carbon Credit Token abstract contract AbstractToken is ICarbonCreditTokenInterface, Initializable, OwnableUpgradeable, ERC20Upgradeable { /// @notice Emitted when the underlying is retired. /// @param amount - the amount retired /// @param checksum - the checksum associated with the retirement event event FinalizeRetirement(uint256 amount, bytes32 checksum); /// @notice user mapping to the amount of retired tokens mapping (address => uint256) internal _retiredBalances; /// @notice number of tokens retired by the user but not yet retired underlyings uint256 public awaitingRetirement; /// @notice number of tokens fully retired uint256 public retired; struct Retirements { uint time; uint amount; } /// @dev a mapping of user to retirements to make them discoverable mapping(address => Retirements[]) private _retirements; /// @dev via ICarbonCreditTokenInterface function retirementCountOf(address address_) external view returns(uint256) { return _retirements[address_].length; } /// @dev via ICarbonCreditTokenInterface function retirementAmountAtIndex(address address_, uint256 index_) external view returns(uint256) { return _retirements[address_][index_].amount; } /// @dev via ICarbonCreditTokenInterface function retirementTimeAtIndex(address address_, uint256 index_) external view returns(uint256) { return _retirements[address_][index_].time; } function __AbstractToken_init( string memory name_, string memory symbol_, address owner_ ) internal initializer { __ERC20_init(name_, symbol_); __Ownable_init(); transferOwnership(owner_); } //// @dev via ICarbonCreditTokenInterface function retiredBalanceOf(address account_) external view returns (uint256) { return _retiredBalances[account_]; } /// @dev via ICarbonCreditTokenInterface function retire(uint256 amount_) external { address account = _msgSender(); _burn(account, amount_); _retiredBalances[account] += amount_; awaitingRetirement += amount_; _retirements[account].push(Retirements(block.timestamp, amount_)); emit Retire(account, amount_); } }
/project_/contracts/abstracts/AbstractTokenFactory.sol
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.9; import '@openzeppelin/contracts/access/Ownable.sol'; import "../interfaces/ICarbonCreditTokenInterface.sol"; /// @author FlowCarbon LLC /// @title A Carbon Credit Token Factory abstract contract AbstractTokenFactory is Ownable { /// @notice Emitted after the implementation contract has been swapped /// @param contractAddress - the address of the new implementation contract event SwappedImplementationContract(address contractAddress); /// @notice Emitted after a new token has been created by this factory /// @param tokenAddress - the address of the freshly deployed contract event TokenCreated(address tokenAddress); /// @notice The implementation contract used to create new tokens address public implementationContract; /// @dev discoverable contracts that have been deployed by this factory address[] public deployedContracts; /// @notice The owner is able to swap out the underlying token implementation /// @param implementationContract_ - the contract about to be used next function swapImplementationContract(ICarbonCreditTokenInterface implementationContract_) onlyOwner public returns (bool) { address contractAddress = address(implementationContract_); require(contractAddress != address(0), "zero address given as implementation contract"); implementationContract = contractAddress; emit SwappedImplementationContract(contractAddress); return true; } /// @notice the number of contracts deployed by this factory function deployedContractsCount() external view returns (uint256) { return deployedContracts.length; } /// @dev internal function that should be called after each clone /// @param address_ a freshly created token address function finalizeCreation(address address_) internal { deployedContracts.push(address_); emit TokenCreated(address_); } }
/project_/contracts/interfaces/ICarbonCreditTokenInterface.sol
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.9; /// @author FlowCarbon LLC /// @title The common interface of carbon credit tokens interface ICarbonCreditTokenInterface { /// @notice Emitted when someone retires a token /// @param account - the retiring account /// @param amount - the amount retired event Retire(address account, uint256 amount); /// @notice retires on behalf of the the user /// @dev this will only retire tokens send by msg.sender, increases tokens awaiting finalization /// @param amount_ - the number of tokens to be retires function retire(uint256 amount_) external; /// @param account_ - the account that wants to check the number of retired tokens /// @return the number of retired tokens for the given account function retiredBalanceOf(address account_) external view returns (uint256); /// @param checksum_ the checksum of the associated retirement event of the underlying /// @return the number of tokens that have been retired with this checksum function amountRetiredWithChecksum(bytes32 checksum_) external view returns (uint256); /// @notice returns the number of retirements for the given address /// @dev this is a pattern to discover all retirements and their occurrences for a user /// @param address_ address of the user who did the retirements function retirementCountOf(address address_) external view returns(uint256); /// @notice returns amount of retired tokens for the given address and key /// @param address_ address of the user who did the retirements /// @param index_ index from userRetirementCount() function retirementAmountAtIndex(address address_, uint256 index_) external view returns(uint256); /// @notice returns the timestamp of a retirement for the given address and key /// @param address_ address of the user who did the retirements /// @param index_ index from userRetirementCount() function retirementTimeAtIndex(address address_, uint256 index_) external view returns(uint256); }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"implementationContract_","internalType":"contract CarbonCreditToken"},{"type":"address","name":"owner_","internalType":"address"}]},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SwappedImplementationContract","inputs":[{"type":"address","name":"contractAddress","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"TokenCreated","inputs":[{"type":"address","name":"tokenAddress","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"createCarbonCreditToken","inputs":[{"type":"string","name":"name_","internalType":"string"},{"type":"string","name":"symbol_","internalType":"string"},{"type":"tuple","name":"details_","internalType":"struct CarbonCreditToken.TokenDetails","components":[{"type":"string","name":"methodology","internalType":"string"},{"type":"string","name":"creditType","internalType":"string"},{"type":"uint16","name":"vintage","internalType":"uint16"}]},{"type":"address","name":"owner_","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"deployedContracts","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"deployedContractsCount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"implementationContract","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"swapImplementationContract","inputs":[{"type":"address","name":"implementationContract_","internalType":"contract ICarbonCreditTokenInterface"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b50604051610bc1380380610bc183398101604081905261002f91610285565b61003833610052565b610041826100a2565b5061004b816101b7565b50506102bf565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080546001600160a01b031633146100f05760405162461bcd60e51b81526020600482018190526024820152600080516020610ba183398151915260448201526064015b60405180910390fd5b816001600160a01b03811661015d5760405162461bcd60e51b815260206004820152602d60248201527f7a65726f206164647265737320676976656e20617320696d706c656d656e746160448201526c1d1a5bdb8818dbdb9d1c9858dd609a1b60648201526084016100e7565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527fdc35e5066ca308b1097337e1466c555053bd2c9dc4a14bc1ed75e09e2e5f710e9060200160405180910390a150600192915050565b6000546001600160a01b031633146101ff5760405162461bcd60e51b81526020600482018190526024820152600080516020610ba183398151915260448201526064016100e7565b6001600160a01b0381166102645760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016100e7565b61026d81610052565b50565b6001600160a01b038116811461026d57600080fd5b6000806040838503121561029857600080fd5b82516102a381610270565b60208401519092506102b481610270565b809150509250929050565b6108d3806102ce6000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806399e7d0561161005b57806399e7d056146100f75780639ad1ee101461010a578063e9065f3d1461011d578063f2fde38b1461012e57600080fd5b80635fc3337f1461008d578063715018a6146100b55780638da5cb5b146100bf57806391905c94146100e4575b600080fd5b6100a061009b366004610576565b610141565b60405190151581526020015b60405180910390f35b6100bd61023e565b005b6000546001600160a01b03165b6040516001600160a01b0390911681526020016100ac565b6100cc6100f2366004610671565b610274565b6001546100cc906001600160a01b031681565b6100cc61011836600461077a565b610330565b6002546040519081526020016100ac565b6100bd61013c366004610576565b61035a565b600080546001600160a01b031633146101755760405162461bcd60e51b815260040161016c90610793565b60405180910390fd5b816001600160a01b0381166101e25760405162461bcd60e51b815260206004820152602d60248201527f7a65726f206164647265737320676976656e20617320696d706c656d656e746160448201526c1d1a5bdb8818dbdb9d1c9858dd609a1b606482015260840161016c565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527fdc35e5066ca308b1097337e1466c555053bd2c9dc4a14bc1ed75e09e2e5f710e9060200160405180910390a160019150505b919050565b6000546001600160a01b031633146102685760405162461bcd60e51b815260040161016c90610793565b61027260006103f5565b565b600080546001600160a01b0316331461029f5760405162461bcd60e51b815260040161016c90610793565b6001546000906102b7906001600160a01b0316610445565b60405163ae44893f60e01b81529091506001600160a01b0382169063ae44893f906102ec908990899089908990600401610815565b600060405180830381600087803b15801561030657600080fd5b505af115801561031a573d6000803e3d6000fd5b50505050610327816104dd565b95945050505050565b6002818154811061034057600080fd5b6000918252602090912001546001600160a01b0316905081565b6000546001600160a01b031633146103845760405162461bcd60e51b815260040161016c90610793565b6001600160a01b0381166103e95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161016c565b6103f2816103f5565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528260601b60148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09150506001600160a01b0381166102395760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b604482015260640161016c565b600280546001810182556000919091527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0319166001600160a01b0383169081179091556040519081527f2e2b3f61b70d2d131b2a807371103cc98d51adcaa5e9a8f9c32658ad8426e74e9060200160405180910390a150565b6001600160a01b03811681146103f257600080fd5b60006020828403121561058857600080fd5b813561059381610561565b9392505050565b634e487b7160e01b600052604160045260246000fd5b6040516060810167ffffffffffffffff811182821017156105d3576105d361059a565b60405290565b600082601f8301126105ea57600080fd5b813567ffffffffffffffff808211156106055761060561059a565b604051601f8301601f19908116603f0116810190828211818310171561062d5761062d61059a565b8160405283815286602085880101111561064657600080fd5b836020870160208301376000602085830101528094505050505092915050565b803561023981610561565b6000806000806080858703121561068757600080fd5b843567ffffffffffffffff8082111561069f57600080fd5b6106ab888389016105d9565b955060208701359150808211156106c157600080fd5b6106cd888389016105d9565b945060408701359150808211156106e357600080fd5b90860190606082890312156106f757600080fd5b6106ff6105b0565b82358281111561070e57600080fd5b61071a8a8286016105d9565b82525060208301358281111561072f57600080fd5b61073b8a8286016105d9565b6020830152506040830135925061ffff8316831461075857600080fd5b604081019290925250915061076f60608601610666565b905092959194509250565b60006020828403121561078c57600080fd5b5035919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6000815180845260005b818110156107ee576020818501810151868301820152016107d2565b81811115610800576000602083870101525b50601f01601f19169290920160200192915050565b60808152600061082860808301876107c8565b828103602084015261083a81876107c8565b9050828103604084015284516060825261085760608301826107c8565b90506020860151828203602084015261087082826107c8565b60409788015161ffff1693909701929092525050506001600160a01b03919091166060909101529291505056fea2646970667358221220e0f942a80236b8f4d9e03dd8a87104c2bb721ff8a0de71a9ef547ad5bdca911064736f6c634300080900334f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572000000000000000000000000cd52b8daa9619d905791bb30d11399eaf25205de0000000000000000000000000ab90e6c97dfc96bebecca4aeb668838212839f4
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100885760003560e01c806399e7d0561161005b57806399e7d056146100f75780639ad1ee101461010a578063e9065f3d1461011d578063f2fde38b1461012e57600080fd5b80635fc3337f1461008d578063715018a6146100b55780638da5cb5b146100bf57806391905c94146100e4575b600080fd5b6100a061009b366004610576565b610141565b60405190151581526020015b60405180910390f35b6100bd61023e565b005b6000546001600160a01b03165b6040516001600160a01b0390911681526020016100ac565b6100cc6100f2366004610671565b610274565b6001546100cc906001600160a01b031681565b6100cc61011836600461077a565b610330565b6002546040519081526020016100ac565b6100bd61013c366004610576565b61035a565b600080546001600160a01b031633146101755760405162461bcd60e51b815260040161016c90610793565b60405180910390fd5b816001600160a01b0381166101e25760405162461bcd60e51b815260206004820152602d60248201527f7a65726f206164647265737320676976656e20617320696d706c656d656e746160448201526c1d1a5bdb8818dbdb9d1c9858dd609a1b606482015260840161016c565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527fdc35e5066ca308b1097337e1466c555053bd2c9dc4a14bc1ed75e09e2e5f710e9060200160405180910390a160019150505b919050565b6000546001600160a01b031633146102685760405162461bcd60e51b815260040161016c90610793565b61027260006103f5565b565b600080546001600160a01b0316331461029f5760405162461bcd60e51b815260040161016c90610793565b6001546000906102b7906001600160a01b0316610445565b60405163ae44893f60e01b81529091506001600160a01b0382169063ae44893f906102ec908990899089908990600401610815565b600060405180830381600087803b15801561030657600080fd5b505af115801561031a573d6000803e3d6000fd5b50505050610327816104dd565b95945050505050565b6002818154811061034057600080fd5b6000918252602090912001546001600160a01b0316905081565b6000546001600160a01b031633146103845760405162461bcd60e51b815260040161016c90610793565b6001600160a01b0381166103e95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161016c565b6103f2816103f5565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528260601b60148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09150506001600160a01b0381166102395760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b604482015260640161016c565b600280546001810182556000919091527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0319166001600160a01b0383169081179091556040519081527f2e2b3f61b70d2d131b2a807371103cc98d51adcaa5e9a8f9c32658ad8426e74e9060200160405180910390a150565b6001600160a01b03811681146103f257600080fd5b60006020828403121561058857600080fd5b813561059381610561565b9392505050565b634e487b7160e01b600052604160045260246000fd5b6040516060810167ffffffffffffffff811182821017156105d3576105d361059a565b60405290565b600082601f8301126105ea57600080fd5b813567ffffffffffffffff808211156106055761060561059a565b604051601f8301601f19908116603f0116810190828211818310171561062d5761062d61059a565b8160405283815286602085880101111561064657600080fd5b836020870160208301376000602085830101528094505050505092915050565b803561023981610561565b6000806000806080858703121561068757600080fd5b843567ffffffffffffffff8082111561069f57600080fd5b6106ab888389016105d9565b955060208701359150808211156106c157600080fd5b6106cd888389016105d9565b945060408701359150808211156106e357600080fd5b90860190606082890312156106f757600080fd5b6106ff6105b0565b82358281111561070e57600080fd5b61071a8a8286016105d9565b82525060208301358281111561072f57600080fd5b61073b8a8286016105d9565b6020830152506040830135925061ffff8316831461075857600080fd5b604081019290925250915061076f60608601610666565b905092959194509250565b60006020828403121561078c57600080fd5b5035919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6000815180845260005b818110156107ee576020818501810151868301820152016107d2565b81811115610800576000602083870101525b50601f01601f19169290920160200192915050565b60808152600061082860808301876107c8565b828103602084015261083a81876107c8565b9050828103604084015284516060825261085760608301826107c8565b90506020860151828203602084015261087082826107c8565b60409788015161ffff1693909701929092525050506001600160a01b03919091166060909101529291505056fea2646970667358221220e0f942a80236b8f4d9e03dd8a87104c2bb721ff8a0de71a9ef547ad5bdca911064736f6c63430008090033