├── IcERC20 ├── ERC20.sol ├── IcERC20.sol └── IcERC20Interface.sol ├── IcERC712 └── IcERC721.sol ├── LICENSE ├── README.md ├── docs └── precompiles │ ├── AbstractAccount │ ├── AbstractAccountAbi.json │ └── AbstractAccountInterface.sol │ ├── EvmInterpreter │ ├── EvmInterpreterAbi.json │ └── EvmInterpreterInterface.sol │ ├── InterTx │ ├── InterTxAbi.json │ └── InterTxInterface.sol │ ├── PrecompileWrap.sol │ └── Quasar │ ├── CosmosSdkAbi.json │ ├── CosmosSdkInterface.sol │ ├── README.md │ └── test │ ├── ProxyContract.sol │ └── RecursiveProxyContract.sol ├── multi-chain-simple-storage ├── README.md ├── SimpleStorage.sol ├── SimpleStorageAbi.json └── SimpleStorageMark.json └── nBridge ├── README.md └── nBridgeMark.json /IcERC20/ERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 7 | import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; 8 | import "@openzeppelin/contracts/utils/Context.sol"; 9 | 10 | /** 11 | * @dev Implementation of the {IERC20} interface. 12 | * 13 | * This implementation is agnostic to the way tokens are created. This means 14 | * that a supply mechanism has to be added in a derived contract using {_mint}. 15 | * For a generic mechanism see {ERC20PresetMinterPauser}. 16 | * 17 | * TIP: For a detailed writeup see our guide 18 | * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How 19 | * to implement supply mechanisms]. 20 | * 21 | * We have followed general OpenZeppelin Contracts guidelines: functions revert 22 | * instead returning `false` on failure. This behavior is nonetheless 23 | * conventional and does not conflict with the expectations of ERC20 24 | * applications. 25 | * 26 | * Additionally, an {Approval} event is emitted on calls to {transferFrom}. 27 | * This allows applications to reconstruct the allowance for all accounts just 28 | * by listening to said events. Other implementations of the EIP may not emit 29 | * these events, as it isn't required by the specification. 30 | * 31 | * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} 32 | * functions have been added to mitigate the well-known issues around setting 33 | * allowances. See {IERC20-approve}. 34 | */ 35 | contract ERC20 is Context, IERC20, IERC20Metadata { 36 | mapping(address => uint256) internal _balances; 37 | 38 | mapping(address => mapping(address => uint256)) internal _allowances; 39 | 40 | uint256 internal _totalSupply; 41 | 42 | string private _name; 43 | string private _symbol; 44 | 45 | /** 46 | * @dev Sets the values for {name} and {symbol}. 47 | * 48 | * The default value of {decimals} is 18. To select a different value for 49 | * {decimals} you should overload it. 50 | * 51 | * All two of these values are immutable: they can only be set once during 52 | * construction. 53 | */ 54 | constructor(string memory name_, string memory symbol_) { 55 | _name = name_; 56 | _symbol = symbol_; 57 | } 58 | 59 | /** 60 | * @dev Returns the name of the token. 61 | */ 62 | function name() public view virtual override returns (string memory) { 63 | return _name; 64 | } 65 | 66 | /** 67 | * @dev Returns the symbol of the token, usually a shorter version of the 68 | * name. 69 | */ 70 | function symbol() public view virtual override returns (string memory) { 71 | return _symbol; 72 | } 73 | 74 | /** 75 | * @dev Returns the number of decimals used to get its user representation. 76 | * For example, if `decimals` equals `2`, a balance of `505` tokens should 77 | * be displayed to a user as `5.05` (`505 / 10 ** 2`). 78 | * 79 | * Tokens usually opt for a value of 18, imitating the relationship between 80 | * Ether and Wei. This is the value {ERC20} uses, unless this function is 81 | * overridden; 82 | * 83 | * NOTE: This information is only used for _display_ purposes: it in 84 | * no way affects any of the arithmetic of the contract, including 85 | * {IERC20-balanceOf} and {IERC20-transfer}. 86 | */ 87 | function decimals() public view virtual override returns (uint8) { 88 | return 18; 89 | } 90 | 91 | /** 92 | * @dev See {IERC20-totalSupply}. 93 | */ 94 | function totalSupply() public view virtual override returns (uint256) { 95 | return _totalSupply; 96 | } 97 | 98 | /** 99 | * @dev See {IERC20-balanceOf}. 100 | */ 101 | function balanceOf(address account) public view virtual override returns (uint256) { 102 | return _balances[account]; 103 | } 104 | 105 | /** 106 | * @dev See {IERC20-transfer}. 107 | * 108 | * Requirements: 109 | * 110 | * - `to` cannot be the zero address. 111 | * - the caller must have a balance of at least `amount`. 112 | */ 113 | function transfer(address to, uint256 amount) public virtual override returns (bool) { 114 | address owner = _msgSender(); 115 | _transfer(owner, to, amount); 116 | return true; 117 | } 118 | 119 | /** 120 | * @dev See {IERC20-allowance}. 121 | */ 122 | function allowance(address owner, address spender) public view virtual override returns (uint256) { 123 | return _allowances[owner][spender]; 124 | } 125 | 126 | /** 127 | * @dev See {IERC20-approve}. 128 | * 129 | * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on 130 | * `transferFrom`. This is semantically equivalent to an infinite approval. 131 | * 132 | * Requirements: 133 | * 134 | * - `spender` cannot be the zero address. 135 | */ 136 | function approve(address spender, uint256 amount) public virtual override returns (bool) { 137 | address owner = _msgSender(); 138 | _approve(owner, spender, amount); 139 | return true; 140 | } 141 | 142 | /** 143 | * @dev See {IERC20-transferFrom}. 144 | * 145 | * Emits an {Approval} event indicating the updated allowance. This is not 146 | * required by the EIP. See the note at the beginning of {ERC20}. 147 | * 148 | * NOTE: Does not update the allowance if the current allowance 149 | * is the maximum `uint256`. 150 | * 151 | * Requirements: 152 | * 153 | * - `from` and `to` cannot be the zero address. 154 | * - `from` must have a balance of at least `amount`. 155 | * - the caller must have allowance for ``from``'s tokens of at least 156 | * `amount`. 157 | */ 158 | function transferFrom( 159 | address from, 160 | address to, 161 | uint256 amount 162 | ) public virtual override returns (bool) { 163 | address spender = _msgSender(); 164 | _spendAllowance(from, spender, amount); 165 | _transfer(from, to, amount); 166 | return true; 167 | } 168 | 169 | /** 170 | * @dev Atomically increases the allowance granted to `spender` by the caller. 171 | * 172 | * This is an alternative to {approve} that can be used as a mitigation for 173 | * problems described in {IERC20-approve}. 174 | * 175 | * Emits an {Approval} event indicating the updated allowance. 176 | * 177 | * Requirements: 178 | * 179 | * - `spender` cannot be the zero address. 180 | */ 181 | function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { 182 | address owner = _msgSender(); 183 | _approve(owner, spender, allowance(owner, spender) + addedValue); 184 | return true; 185 | } 186 | 187 | /** 188 | * @dev Atomically decreases the allowance granted to `spender` by the caller. 189 | * 190 | * This is an alternative to {approve} that can be used as a mitigation for 191 | * problems described in {IERC20-approve}. 192 | * 193 | * Emits an {Approval} event indicating the updated allowance. 194 | * 195 | * Requirements: 196 | * 197 | * - `spender` cannot be the zero address. 198 | * - `spender` must have allowance for the caller of at least 199 | * `subtractedValue`. 200 | */ 201 | function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { 202 | address owner = _msgSender(); 203 | uint256 currentAllowance = allowance(owner, spender); 204 | require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); 205 | unchecked { 206 | _approve(owner, spender, currentAllowance - subtractedValue); 207 | } 208 | 209 | return true; 210 | } 211 | 212 | /** 213 | * @dev Moves `amount` of tokens from `from` to `to`. 214 | * 215 | * This internal function is equivalent to {transfer}, and can be used to 216 | * e.g. implement automatic token fees, slashing mechanisms, etc. 217 | * 218 | * Emits a {Transfer} event. 219 | * 220 | * Requirements: 221 | * 222 | * - `from` cannot be the zero address. 223 | * - `to` cannot be the zero address. 224 | * - `from` must have a balance of at least `amount`. 225 | */ 226 | function _transfer( 227 | address from, 228 | address to, 229 | uint256 amount 230 | ) internal virtual { 231 | require(from != address(0), "ERC20: transfer from the zero address"); 232 | require(to != address(0), "ERC20: transfer to the zero address"); 233 | 234 | _beforeTokenTransfer(from, to, amount); 235 | 236 | uint256 fromBalance = _balances[from]; 237 | require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); 238 | unchecked { 239 | _balances[from] = fromBalance - amount; 240 | } 241 | _balances[to] += amount; 242 | 243 | emit Transfer(from, to, amount); 244 | 245 | _afterTokenTransfer(from, to, amount); 246 | } 247 | 248 | /** @dev Creates `amount` tokens and assigns them to `account`, increasing 249 | * the total supply. 250 | * 251 | * Emits a {Transfer} event with `from` set to the zero address. 252 | * 253 | * Requirements: 254 | * 255 | * - `account` cannot be the zero address. 256 | */ 257 | function _mint(address account, uint256 amount) internal virtual { 258 | require(account != address(0), "ERC20: mint to the zero address"); 259 | 260 | _beforeTokenTransfer(address(0), account, amount); 261 | 262 | _totalSupply += amount; 263 | _balances[account] += amount; 264 | emit Transfer(address(0), account, amount); 265 | 266 | _afterTokenTransfer(address(0), account, amount); 267 | } 268 | 269 | /** 270 | * @dev Destroys `amount` tokens from `account`, reducing the 271 | * total supply. 272 | * 273 | * Emits a {Transfer} event with `to` set to the zero address. 274 | * 275 | * Requirements: 276 | * 277 | * - `account` cannot be the zero address. 278 | * - `account` must have at least `amount` tokens. 279 | */ 280 | function _burn(address account, uint256 amount) internal virtual { 281 | require(account != address(0), "ERC20: burn from the zero address"); 282 | 283 | _beforeTokenTransfer(account, address(0), amount); 284 | 285 | uint256 accountBalance = _balances[account]; 286 | require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); 287 | unchecked { 288 | _balances[account] = accountBalance - amount; 289 | } 290 | _totalSupply -= amount; 291 | 292 | emit Transfer(account, address(0), amount); 293 | 294 | _afterTokenTransfer(account, address(0), amount); 295 | } 296 | 297 | /** 298 | * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. 299 | * 300 | * This internal function is equivalent to `approve`, and can be used to 301 | * e.g. set automatic allowances for certain subsystems, etc. 302 | * 303 | * Emits an {Approval} event. 304 | * 305 | * Requirements: 306 | * 307 | * - `owner` cannot be the zero address. 308 | * - `spender` cannot be the zero address. 309 | */ 310 | function _approve( 311 | address owner, 312 | address spender, 313 | uint256 amount 314 | ) internal virtual { 315 | require(owner != address(0), "ERC20: approve from the zero address"); 316 | require(spender != address(0), "ERC20: approve to the zero address"); 317 | 318 | _allowances[owner][spender] = amount; 319 | emit Approval(owner, spender, amount); 320 | } 321 | 322 | /** 323 | * @dev Updates `owner` s allowance for `spender` based on spent `amount`. 324 | * 325 | * Does not update the allowance amount in case of infinite allowance. 326 | * Revert if not enough allowance is available. 327 | * 328 | * Might emit an {Approval} event. 329 | */ 330 | function _spendAllowance( 331 | address owner, 332 | address spender, 333 | uint256 amount 334 | ) internal virtual { 335 | uint256 currentAllowance = allowance(owner, spender); 336 | if (currentAllowance != type(uint256).max) { 337 | require(currentAllowance >= amount, "ERC20: insufficient allowance"); 338 | unchecked { 339 | _approve(owner, spender, currentAllowance - amount); 340 | } 341 | } 342 | } 343 | 344 | /** 345 | * @dev Hook that is called before any transfer of tokens. This includes 346 | * minting and burning. 347 | * 348 | * Calling conditions: 349 | * 350 | * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens 351 | * will be transferred to `to`. 352 | * - when `from` is zero, `amount` tokens will be minted for `to`. 353 | * - when `to` is zero, `amount` of ``from``'s tokens will be burned. 354 | * - `from` and `to` are never both zero. 355 | * 356 | * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. 357 | */ 358 | function _beforeTokenTransfer( 359 | address from, 360 | address to, 361 | uint256 amount 362 | ) internal virtual {} 363 | 364 | /** 365 | * @dev Hook that is called after any transfer of tokens. This includes 366 | * minting and burning. 367 | * 368 | * Calling conditions: 369 | * 370 | * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens 371 | * has been transferred to `to`. 372 | * - when `from` is zero, `amount` tokens have been minted for `to`. 373 | * - when `to` is zero, `amount` of ``from``'s tokens have been burned. 374 | * - `from` and `to` are never both zero. 375 | * 376 | * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. 377 | */ 378 | function _afterTokenTransfer( 379 | address from, 380 | address to, 381 | uint256 amount 382 | ) internal virtual {} 383 | } 384 | -------------------------------------------------------------------------------- /IcERC20/IcERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | import "./ERC20.sol"; 6 | 7 | contract ICERC20 is ERC20 { 8 | address public AbstractAccountsAddress = 0x000000000000000000000000000000000000001a; 9 | 10 | event ICMove(uint256 sourceChainID, uint256 targetChainID, address indexed _fromto, uint256 _value); 11 | event ICTransfer(uint256 sourceChainID, uint256 targetChainID, address indexed _from, address indexed _to, uint256 _value); 12 | 13 | constructor(uint256 initialSupply, uint256 _chainId, address owner) ERC20("ICToken", "ICT") { 14 | uint256 chainId = getChainId(); 15 | if (_chainId == chainId) { 16 | _mint(owner, initialSupply); 17 | } 18 | else { 19 | _totalSupply = initialSupply; 20 | } 21 | } 22 | 23 | function ICbalanceOf(uint256 ICchainID, address _owner) public view returns (uint256 balance) { 24 | // Not implemented; needs routing of queries 25 | } 26 | 27 | function ICallowance(uint256 ICchainID, address _owner, address _spender) public view returns (uint256 remaining) { 28 | // Not implemented; needs routing of queries 29 | } 30 | 31 | function ICmove(uint256 sourceChainID, uint256 targetChainID, address _from, uint256 _value) public returns (bool success) { 32 | require(msg.sender == getAbstractAccountAddress(_from), "Abstract account not authorized"); 33 | uint256 chainId = getChainId(); 34 | if (sourceChainID == chainId) { 35 | _subtract(_from, _value); 36 | } 37 | else if (targetChainID == chainId) { 38 | _add(_from, _value); 39 | } 40 | 41 | emit ICMove(sourceChainID, targetChainID, _from, _value); 42 | } 43 | 44 | function ICtransfer(uint256 sourceChainID, uint256 targetChainID, address _from, address _to, uint256 _value) public returns (bool success) { 45 | require(msg.sender == getAbstractAccountAddress(_from), "Abstract account not authorized"); 46 | uint256 chainId = getChainId(); 47 | if (sourceChainID == chainId) { 48 | _subtract(_from, _value); 49 | } 50 | else if (targetChainID == chainId) { 51 | _add(_to, _value); 52 | } 53 | 54 | emit ICTransfer(sourceChainID, targetChainID, _from, _to, _value); 55 | } 56 | 57 | function getChainId() public view returns(uint256 chainId) { 58 | assembly { 59 | chainId := chainid() 60 | } 61 | } 62 | 63 | function getAbstractAccountAddress(address owner) internal returns (address account) { 64 | bytes memory payload = abi.encodeWithSignature( 65 | "getAccountAddress(address)", 66 | owner 67 | ); 68 | 69 | (bool success, bytes memory data) = AbstractAccountsAddress.call(payload); 70 | if (!success) revert("AA precompile getAccountAddress failed"); 71 | bytes memory res = abi.decode(data, (bytes)); 72 | account = abi.decode(res, (address)); 73 | return account; 74 | } 75 | 76 | function _subtract( 77 | address from, 78 | uint256 amount 79 | ) internal { 80 | require(from != address(0), "ERC20: subtract from the zero address"); 81 | 82 | uint256 fromBalance = _balances[from]; 83 | require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); 84 | unchecked { 85 | _balances[from] = fromBalance - amount; 86 | } 87 | } 88 | 89 | function _add( 90 | address to, 91 | uint256 amount 92 | ) internal { 93 | require(to != address(0), "ERC20: add to the zero address"); 94 | uint256 toBalance = _balances[to]; 95 | _balances[to] += amount; 96 | require(toBalance <= _balances[to], "ERC20: add amount underflow"); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /IcERC20/IcERC20Interface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | interface IcERC20 { 6 | function name() external view returns (string memory); 7 | function symbol() external view returns (string memory); 8 | function decimals() external view returns (uint8); 9 | function totalSupply() external view returns (uint256); 10 | function balanceOf(address _owner) external view returns (uint256 balance); 11 | function allowance(address _owner, address _spender) external view returns (uint256 remaining); 12 | 13 | function transfer(address _to, uint256 _value) external returns (bool success); 14 | function transferFrom(address _from, address _to, uint256 _value) external returns (bool success); 15 | function approve(address _spender, uint256 _value) external returns (bool success); 16 | 17 | event Transfer(address indexed _from, address indexed _to, uint256 _value); 18 | event Approval(address indexed _owner, address indexed _spender, uint256 _value); 19 | 20 | // IC-specific 21 | 22 | function ICbalanceOf( 23 | uint8 ICchainID, 24 | address _owner 25 | ) external view returns ( 26 | uint256 balance 27 | ); 28 | 29 | function ICallowance( 30 | uint8 ICchainID, 31 | address _owner, 32 | address _spender 33 | ) external view returns ( 34 | uint256 remaining 35 | ); 36 | 37 | function ICmove( 38 | uint8 sourceChainID, 39 | uint8 targetChainID, 40 | address _from, 41 | uint256 _value 42 | ) external returns ( 43 | bool success 44 | ); 45 | 46 | function ICtransfer( 47 | uint8 sourceChainID, 48 | uint8 targetChainID, 49 | address _from, 50 | address _to, 51 | uint256 _value 52 | ) external returns ( 53 | bool success 54 | ); 55 | 56 | event ICMove( 57 | uint8 sourceChainID, 58 | uint8 targetChainID, 59 | address indexed _fromto, 60 | uint256 _value 61 | ); 62 | 63 | event ICTransfer( 64 | uint8 sourceChainID, 65 | uint8 targetChainID, 66 | address indexed _from, 67 | address indexed _to, 68 | uint256 _value 69 | ); 70 | } -------------------------------------------------------------------------------- /IcERC712/IcERC721.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | interface IcERC721 { 6 | function balanceOf(address _owner) external view returns (uint256); 7 | function ownerOf(uint256 _tokenId) external view returns (address); 8 | function getApproved(uint256 _tokenId) external view returns (address); 9 | function isApprovedForAll(address _owner, address _operator) external view returns (bool); 10 | 11 | function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable; 12 | function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable; 13 | function transferFrom(address _from, address _to, uint256 _tokenId) external payable; 14 | function approve(address _approved, uint256 _tokenId) external payable; 15 | function setApprovalForAll(address _operator, bool _approved) external; 16 | 17 | event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId); 18 | event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId); 19 | event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved); 20 | 21 | // IC-specific 22 | 23 | function ICbalanceOf( 24 | uint8 ICchainID, 25 | address _owner 26 | ) public view returns ( 27 | uint256 balance 28 | ) 29 | 30 | //function ICallowance(uint8 ICchainID, address _owner, address _spender) public view returns (uint256 remaining) 31 | 32 | function ICmove( 33 | uint8 sourceChainID, 34 | uint8 targetChainID, 35 | address _from, 36 | uint256 _tokenId 37 | ) public returns ( 38 | bool success 39 | ) 40 | 41 | function ICtransfer( 42 | uint8 sourceChainID, 43 | uint8 targetChainID, 44 | address _from, 45 | address _to, 46 | uint256 _tokenId 47 | ) public returns ( 48 | bool success 49 | ) 50 | 51 | event ICMove( 52 | uint8 sourceChainID, 53 | uint8 targetChainID, 54 | address indexed _fromto, 55 | uint256 indexed _tokenId 56 | ) 57 | 58 | event ICTransfer( 59 | uint8 sourceChainID, 60 | uint8 targetChainID, 61 | address indexed _from, 62 | address indexed _to, 63 | uint256 indexed _tokenId 64 | ) 65 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The EVM for the Inter-Chain 2 | 3 | Register for tokens: https://docs.google.com/forms/d/e/1FAIpQLSebODebNu4eSVBGIY3EowXqHQTTaLAFngMiWHihVeKeHWuWYQ/viewform 4 | 5 | For tech support you can ask a question on 6 | - Mythos Discord, #support channel: https://discord.gg/DQn3f4yu 7 | 8 | ## UPDATE! 9 | 10 | _The information below is outdated. We no longer use Ethermint for our chains. We have implemented our own eWASM engine for Cosmos SDK chains. If you want to test it, you can join the Mythos Discord with the above link._ 11 | 12 | ## About 13 | 14 | Mythos, Ethos and Logos are Cosmos-EVM cutting-edge chains [based on Ethermint](https://github.com/evmos/ethermint) (and therefore Evmos-compatible) that host live, publicly verifiable prototypes of our work at The Laurel Project https://laurel.provable.dev. 15 | 16 | We showcase innovative features that Cosmos-EVM chains can have, some of which have been/will be proposed to Evmos. This is the future of Cosmos-EVM and you can help us build it. 17 | 18 | All this effort is volunteer effort. To support these EVM inter-chain projects on Evmos, you can join as a volunteer or give 100% of your staking reward to our validator: https://evolve.provable.dev/. 19 | 20 | Note: the Mythos, Logos, Ethos tokens do not have value outside of transaction gas. Mythos, Logos, Ethos might be restarted from scratch at a later time, (1 month after the hackathon). 21 | 22 | ## Quasar Demo 23 | 24 | See [./docs/precompiles/Quasar](./docs/precompiles/Quasar) 25 | 26 | *Note*: Information below might be outdated. 27 | 28 | ## Interactive Workshop 29 | 30 | Presentation: https://docs.google.com/presentation/d/1A6kFqRLrCv5n755kU6duAJz2UQdbJlpRqpIADvfJjfM/edit?usp=sharing 31 | 32 | ### Prerequsite 33 | 34 | - Install Metamask (or another EVM wallet) in your browser (ideally Chrome): https://metamask.io/ 35 | - Fill in this form with your Ethereum address, to receive tokens on the Mythos, Ethos, Logos chains: https://forms.gle/3sGGBEPzqLQM7Zp7A 36 | - Add Mythos, Logos, Ethos to your Metamask: 37 | 38 | #### Mythos Metamask settings: 39 | * Name: `mythos.provable.dev` 40 | * RPC URL: `https://mythos-evm.provable.dev` 41 | * ChainID: `7001` 42 | * Currency: `aMYT` 43 | * Block explorer: `https://explorer-mythos.provable.dev/` 44 | 45 | #### Logos Metamask settings: 46 | * Name: `logos.provable.dev` 47 | * RPC URL: `https://logos-evm.provable.dev` 48 | * ChainID: `7002` 49 | * Currency: `aLYT` 50 | * Block explorer: `https://explorer-logos.provable.dev` 51 | 52 | #### Ethos Metamask settings: 53 | * Name: `ethos.provable.dev` 54 | * RPC URL: `https://ethos-evm.provable.dev` 55 | * ChainID: `7003` 56 | * Currency: `aRYT` 57 | * Block explorer: `https://explorer-ethos.provable.dev` 58 | 59 | 60 | ### Setup 61 | 62 | MacOS binaries: https://drive.google.com/file/d/1USKotmn882BzVVhWDiirf3TZy9Oz_nQl/view?usp=sharing 63 | Binaries are only needed for the Cosmos SDK part of: opening an interchain account, forwarding the abstract account across chains and sending tokens for each interchain account (on each chain). Some of these messages are also exposed on the EVM side, in the precompiles (Quasar feature). The intent is to expose all of them in the EVM. 64 | 65 | - register for tokens and support to do the setup 66 | - create interchain accounts for your Ethereum address (replace with the account that you have) 67 | 68 | ``` 69 | mythosd tx intertx register --from mythos1kjuzm2lsa8ndlc904gvnex9lur8tuputpzq928 --connection-id connection-0 --chain-id mythos_7001-1 --node https://mythos-rpc.provable.dev:443 --home ~/.mythosd --fees 30aMYT --gas=251206 -y 70 | ``` 71 | 72 | - it may take 1-2 min to create, check creation with: 73 | ``` 74 | mythosd q intertx account-interchain mythos1kjuzm2lsa8ndlc904gvnex9lur8tuputpzq928 connection-0 --chain-id mythos_7001-1 --node https://mythos-rpc.provable.dev:443 75 | ``` 76 | 77 | - send funds to your interchain account on Logos: (replace the inter-chain account address with yours) 78 | ``` 79 | logosd tx bank send logos1kjuzm2lsa8ndlc904gvnex9lur8tuputgvrq5e logos1eqtc4q6sxt9lglqz8nuvtn0e2cxmrpkkwgkj3dyf9x0vh5lq0nzse9mc7m 1000000000000000000aLYT --fees 20aLYT --chain-id logos_7002-1 --node https://logos-rpc.provable.dev:443 --home ~/.logosd --keyring-backend test -y 80 | 81 | # check balance 82 | logosd q bank balances logos1eqtc4q6sxt9lglqz8nuvtn0e2cxmrpkkwgkj3dyf9x0vh5lq0nzse9mc7m --chain-id logos_7002-1 --node https://logos-rpc.provable.dev:443 --home ~/.logosd 83 | ``` 84 | 85 | - repeat same process for Logos and Ethos 86 | 87 | ``` 88 | logosd tx intertx register --from logos1kjuzm2lsa8ndlc904gvnex9lur8tuputgvrq5e --connection-id connection-1 --chain-id logos_7002-1 --node https://logos-rpc.provable.dev:443 --home ~/.logosd --fees 30aLYT --gas=251206 -y 89 | 90 | ethosd tx bank send ethos1kjuzm2lsa8ndlc904gvnex9lur8tuput6gll4p ethos1zz38ahrqfkrrzffqc5eceywz57fspdlh35sqvavk6ufew0m0ectscwmz3u 1000000000000000000aRYT --fees 20aRYT --chain-id ethos_7003-1 --node https://ethos-rpc.provable.dev:443 --home ~/.ethosd --keyring-backend test -y 91 | ``` 92 | 93 | - create and forward the abstract account to each chain - from Mythos -> Logos, from Logos -> Ethos 94 | ``` 95 | mythosd tx intertx account-abstract-forward mythos1kjuzm2lsa8ndlc904gvnex9lur8tuputpzq928 connection-0 --from newacc --chain-id mythos_7001-1 --home ~/.mythosd --node https://mythos-rpc.provable.dev:443 --keyring-backend test --fees 300aMYT -y 96 | 97 | logosd tx intertx account-abstract-forward logos1kjuzm2lsa8ndlc904gvnex9lur8tuputgvrq5e connection-1 --from logos1kjuzm2lsa8ndlc904gvnex9lur8tuputgvrq5e --chain-id logos_7002-1 --home ~/.logosd --node https://logos-rpc.provable.dev:443 --keyring-backend test --fees 300aLYT -y 98 | 99 | mythosd q intertx account-abstract mythos1kjuzm2lsa8ndlc904gvnex9lur8tuputpzq928 "connection-0" --home ~/.mythosd --node https://mythos-rpc.provable.dev:443 100 | ``` 101 | 102 | ### Use nBridge dApp 103 | 104 | To do a multi-chain deploy or a multi-chain transaction. 105 | 106 | https://mark.provable.dev/?ipfs=QmPDfrDDaH8yoNcagz8pwMPsT2tFze7YvjCih9MDWn5XVq&m=e 107 | 108 | ### Multi-Chain Simple Storage 109 | 110 | Deploy a multi-chain SimpleStorage smart contract, modify the state on all chains in a single transaction. 111 | 112 | Smart contract: https://github.com/the-laurel/demos/tree/main/multi-chain-simple-storage. 113 | 114 | Use nBridge dApp. 115 | 116 | Make sure the abstract account has the same nonce on all chains. E.g. if you sent a multi-chain transaction on Mythos and Logos, you must send it on Ethos too, if you want to later be able to replay a second transaction on all three. Otherwise, the second transaction will fail on Ethos. 117 | 118 | ### Inter-Chain ERC20 119 | 120 | Inter-Chain ERC20 (ICERC20) smart contract is at address [Ethereum address]. See contract code & ABI at https://github.com/the-laurel/demos/tree/main/IcERC20. 121 | 122 | A deployed example on Mythos and Logos is at `0x67d71BcE3cdBa17E40883398dB5aec8c6b7e96a3`. 123 | Use nBridge dApp to encode the calldata and send a `replay` dependent transaction. 124 | 125 | You can: 126 | -> move your ICERC20 tokens from Mythos to your account (same Ethereum address) on another chain (Logos, Ethos) 127 | -> transfer your ICERC20 tokens from Mythos to another account, on another chain (Logos, Ethos) 128 | 129 | #### Learn more: 130 | - The EVM Inter-Chain playlist: https://www.youtube.com/playlist?list=PL323JufuD9JCrElzoheW-oJMujGjHtp-k 131 | 132 | ## Tools 133 | 134 | ### Marks Factory 135 | 136 | https://mark.provable.dev/?m=e 137 | 138 | ## The Development Process 139 | 140 | 1. know well your intent and the limitations of the EVM chain 141 | 2. develop the smart contracts in Solidity with Remix 142 | 3. test the ABI in Remix 143 | 4. produce a simple dApp to test independently from Remix 144 | 5. make the dApp intuitive, secure, and bug-free 145 | 6. deploy the contracts on the pubic chain 146 | 7. deploy the dApp on IPFS 147 | 8. profit 148 | 149 | We simplified the process: 150 | 151 | 1. know well your intent and the limitations of the EVM chain 152 | 2. develop the smart contracts in Solidity with Remix or in our taylor IDE 153 | 3. export the ABI to obtain a simple dApp 154 | 4. make the dApp intuitive, secure, and bug-free in the same IDE 155 | 5. press a button and it gets saved to IPFS and QR created for mobile share 156 | 6. deploy the contracts too on the public chain 157 | 7. profit 158 | 159 | For todays lessons, you will receive stubs of code from IPFS. You should be able to further develop the code to work in the Inter-Chain environment. 160 | 161 | Plus: after you develop a dApp, you will be able to share it with the others. 162 | 163 | ## Transaction Replay 164 | 165 | needs to: 166 | - be signed by the same account 167 | - the contract has to have the same address 168 | - with the same nonce 169 | - on each chain that is played on 170 | 171 | We have created 2 types of trustless bridges that use transaction replay: 1 can be used between 2 chains and 1 can be used on 3 or more chains and it uses a router to create a ring of chains. The router selects on wich chains the transaction should be replayed. 172 | 173 | ## Relevant Infrastructure 174 | 175 | ### The Necessay Precompiles 176 | 177 | For ease of use, you can find all the precompile interfaces in `./docs/precompiles/PrecompileWrap.sol`, deployed at `0x320555a5112A4a5572bF37573Ce8973bAeDab9B2`, on Mythos. 178 | 179 | #### EvmInterpreter Precompile 180 | 181 | - Address: `0x0000000000000000000000000000000000000014` 182 | - Interface: https://github.com/the-laurel/demos/tree/main/docs/precompiles/EvmInterpreter 183 | 184 | ### InterTx Precompile 185 | 186 | - Address: `0x0000000000000000000000000000000000000019` 187 | - Interface: https://github.com/the-laurel/demos/tree/main/docs/precompiles/InterTx 188 | 189 | ### AbstractAccount Precompile 190 | 191 | - Address: `0x000000000000000000000000000000000000001a` 192 | - Interface: https://github.com/the-laurel/demos/tree/main/docs/precompiles/AbstractAccount 193 | 194 | ### Quasar/Cosmos Sdk Precompile 195 | 196 | - Address: `0x000000000000000000000000000000000000001d` 197 | - Interface: https://github.com/the-laurel/demos/tree/main/docs/precompiles/CosmosSdk 198 | -------------------------------------------------------------------------------- /docs/precompiles/AbstractAccount/AbstractAccountAbi.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"string","name":"connectionId","type":"string"}],"name":"getAccount","outputs":[{"internalType":"address","name":"accountAddress","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"getAccountAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registerAccount","outputs":[{"internalType":"address","name":"accountAddress","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"sendTx","outputs":[{"internalType":"bytes","name":"response","type":"bytes"},{"internalType":"bytes","name":"error","type":"bytes"}],"stateMutability":"nonpayable","type":"function"}] -------------------------------------------------------------------------------- /docs/precompiles/AbstractAccount/AbstractAccountInterface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | /// @title A precompile for Account Abstractions 6 | /// @author The Laurel Project 7 | /// @notice https://ethereum-magicians.org/t/implementing-account-abstraction-as-part-of-eth1-x/4020 8 | /// @dev Technical demos are at https://www.youtube.com/c/LoredanaCirstea/videos 9 | /// custom:license This is covered by The Moral Licence - that is more strict than GPL-3.0 10 | interface AbstractAccountsPrecompile { 11 | 12 | /// @notice Sends a transaction as from an EOA 13 | /// @param signature is 65 bytes in length and is further composed 1B + 32B + 32B (v, s, r). 14 | /// @return response error can be 0 length when response exists 15 | function sendTx( 16 | address to, 17 | address from, // removed when signature works 18 | uint256 value, 19 | uint256 gasLimit, 20 | bytes memory data, 21 | bytes memory signature 22 | ) external returns(bytes memory response, bytes memory error); 23 | 24 | /// @notice Retrieval of abstract account address by owner 25 | function getAccountAddress(address owner) view external returns (address); 26 | 27 | /// @notice Retrieval of abstract account by owner and IBC channel connectionId 28 | function getAccount(address owner, string memory connectionId) view external returns (address accountAddress, uint256 nonce); 29 | 30 | /// @notice Creation of new abstract accounts 31 | function registerAccount() view external returns(address accountAddress); 32 | } 33 | -------------------------------------------------------------------------------- /docs/precompiles/EvmInterpreter/EvmInterpreterAbi.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"bytes","name":"bytecode","type":"bytes"},{"internalType":"bytes","name":"input","type":"bytes"},{"internalType":"uint256","name":"gas","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"analyze","outputs":[{"internalType":"uint256","name":"pc","type":"uint256"},{"internalType":"uint256","name":"reads","type":"uint256"},{"internalType":"uint256","name":"writes","type":"uint256"},{"internalType":"uint256","name":"calls","type":"uint256"},{"internalType":"uint256","name":"memsize","type":"uint256"},{"internalType":"uint256","name":"gasused","type":"uint256"},{"internalType":"bytes","name":"output","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"bytecodeFrag","type":"bytes"},{"internalType":"bytes32[]","name":"stack","type":"bytes32[]"},{"internalType":"uint256","name":"gas","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"analyzeFrag","outputs":[{"internalType":"uint256","name":"pc","type":"uint256"},{"internalType":"uint256","name":"reads","type":"uint256"},{"internalType":"uint256","name":"writes","type":"uint256"},{"internalType":"uint256","name":"calls","type":"uint256"},{"internalType":"uint256","name":"memsize","type":"uint256"},{"internalType":"uint256","name":"gasused","type":"uint256"},{"internalType":"bytes32[]","name":"stackOut","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"bytecode","type":"bytes"},{"internalType":"bytes","name":"input","type":"bytes"},{"internalType":"uint256","name":"gas","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"interpret","outputs":[{"internalType":"bytes","name":"result","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"readHashInitial","type":"bytes32"},{"internalType":"bytes32[]","name":"writeHashInitial","type":"bytes32[]"},{"internalType":"bytes","name":"bytecode","type":"bytes"},{"internalType":"bytes","name":"input","type":"bytes"},{"internalType":"uint256","name":"gas","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"part","outputs":[{"internalType":"bytes32","name":"readHash","type":"bytes32"},{"internalType":"bytes32[]","name":"writeHash","type":"bytes32[]"},{"internalType":"bytes","name":"result","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"readHashInitial","type":"bytes32"},{"internalType":"bytes32[]","name":"writeHashInitial","type":"bytes32[]"},{"internalType":"bytes","name":"bytecodeFrag","type":"bytes"},{"internalType":"bytes32[]","name":"stack","type":"bytes32[]"},{"internalType":"uint256","name":"gas","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"partFrag","outputs":[{"internalType":"bytes32","name":"readHash","type":"bytes32"},{"internalType":"bytes32[]","name":"writeHash","type":"bytes32[]"},{"internalType":"bytes32[]","name":"stackOut","type":"bytes32[]"}],"stateMutability":"view","type":"function"}] -------------------------------------------------------------------------------- /docs/precompiles/EvmInterpreter/EvmInterpreterInterface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | /// @title A precompile for an EVM Interpreter 6 | /// @author The Laurel Project 7 | /// @notice It helps at developing and debugging in a consensus env 8 | /// @dev Technical demos are at https://www.youtube.com/c/LoredanaCirstea/videos 9 | /// custom:license This is covered by The Moral Licence - that is more strict than GPL-3.0 10 | interface EvmInterpreterPrecompile { 11 | 12 | /// @notice Analyzes a fragment of bytecode 13 | /// @dev Demoed at https://www.youtube.com/watch?v=kHDxDiM5xvQ&list=PL323JufuD9JCE_pGDLHJN-wVBpCPc9Q1G&index=8 14 | /// @param bytecodeFrag Any legal EVM bytecode portion 15 | /// @param stack The EVM Stack configuration before this bytecode is executing 16 | /// @param gas The available gas in Wei 17 | /// @param value The value in Wei sent to the transaction 18 | /// @return pc The Pointer Counter - position of the execution in the bytecode 19 | /// @return reads Number of reads from storage executed 20 | /// @return writes Number of slot writes into storage 21 | /// @return calls Number of external (other) contract calls 22 | /// @return memsize How many bytes of memory had been used 23 | /// @return gasused How much gas is left 24 | /// @return stackOut The EVM Stack configuration after this bytecode is executing 25 | function analyzeFrag( 26 | bytes memory bytecodeFrag, 27 | bytes32[] memory stack, 28 | uint256 gas, 29 | uint256 value 30 | ) view external returns ( 31 | uint256 pc, 32 | uint256 reads, 33 | uint256 writes, 34 | uint256 calls, 35 | uint256 memsize, 36 | uint256 gasused, 37 | bytes32[] memory stackOut 38 | ); 39 | 40 | /// @notice Analyzes a contract call 41 | /// @param bytecode Any legal EVM bytecode (for a presumtive contract) 42 | /// @param input The EVM transaction calldata (for that contract) 43 | /// @param gas The available gas in Wei 44 | /// @param value The value in Wei sent to the transaction 45 | /// @return pc The Pointer Counter - position of the execution in the bytecode 46 | /// @return reads Number of reads from storage executed 47 | /// @return writes Number of slot writes into storage 48 | /// @return calls Number of external (other) contract calls 49 | /// @return memsize How many bytes of memory had been used 50 | /// @return gasused How much gas is left 51 | /// @return output The call result 52 | function analyze( 53 | bytes memory bytecode, 54 | bytes memory input, 55 | uint256 gas, 56 | uint256 value 57 | ) view external returns ( 58 | uint256 pc, 59 | uint256 reads, 60 | uint256 writes, 61 | uint256 calls, 62 | uint256 memsize, 63 | uint256 gasused, 64 | bytes memory output 65 | ); 66 | 67 | /// @notice Executes (immutably) a contract call 68 | /// @param bytecode Any legal EVM bytecode (for a presumtive contract) 69 | /// @param input The EVM transaction calldata (for that contract) 70 | /// @param gas The available gas in Wei 71 | /// @param value The value in Wei sent to the transaction 72 | /// @return result The call result 73 | function interpret( 74 | bytes memory bytecode, 75 | bytes memory input, 76 | uint256 gas, 77 | uint256 value 78 | ) view external returns ( 79 | bytes memory result 80 | ); 81 | 82 | /// @notice Describes the side effects of a call 83 | /// @param readHashInitial Previous reads side effects (for chaining transactions) 84 | /// @param writeHashInitial Previous writes side effects (for chaining transactions) 85 | /// @param bytecode Any legal EVM bytecode (for a presumtive contract) 86 | /// @param input The EVM transaction calldata (for that contract) 87 | /// @param gas The available gas in Wei 88 | /// @param value The value in Wei sent to the transaction 89 | /// @return readHash The read hash after of the execution of this call 90 | /// @return writeHash The write hash after of the execution of this call 91 | /// @return result The call result 92 | function part( 93 | bytes32 readHashInitial, 94 | bytes32[] memory writeHashInitial, 95 | bytes memory bytecode, 96 | bytes memory input, 97 | uint256 gas, 98 | uint256 value 99 | ) view external returns ( 100 | bytes32 readHash, 101 | bytes32[] memory writeHash, 102 | bytes memory result 103 | ); 104 | 105 | /// @notice Describes the side effects of executing a fragment of bytecode 106 | /// @param readHashInitial Previous reads side effects (for chaining transactions) 107 | /// @param writeHashInitial Previous writes side effects (for chaining transactions) 108 | /// @param bytecodeFrag Any legal EVM bytecode fragment 109 | /// @param stack The EVM Stack configuration before this bytecode is executing 110 | /// @param gas The available gas in Wei 111 | /// @param value The value in Wei sent to the transaction 112 | /// @return readHash The read hash after of the execution of this call 113 | /// @return writeHash The write hash after of the execution of this call 114 | /// @return stackOut The EVM Stack configuration after this bytecode is executing 115 | function partFrag( 116 | bytes32 readHashInitial, 117 | bytes32[] memory writeHashInitial, 118 | bytes memory bytecodeFrag, 119 | bytes32[] memory stack, 120 | uint256 gas, 121 | uint256 value 122 | ) view external returns ( 123 | bytes32 readHash, 124 | bytes32[] memory writeHash, 125 | bytes32[] memory stackOut 126 | ); 127 | } -------------------------------------------------------------------------------- /docs/precompiles/InterTx/InterTxAbi.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"string","name":"connectionId","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"emitDependentTx","outputs":[{"internalType":"bytes","name":"response","type":"bytes"},{"internalType":"bytes","name":"error","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"string","name":"connectionId","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"emitTx","outputs":[{"internalType":"bytes","name":"response","type":"bytes"},{"internalType":"bytes","name":"error","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"chainIdentifiers","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"emitTxMulti","outputs":[{"internalType":"bytes","name":"response","type":"bytes"},{"internalType":"bytes","name":"error","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"string","name":"connectionId","type":"string"}],"name":"getInterChainAccountAddress","outputs":[{"internalType":"string","name":"icaAddress","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"string","name":"connectionId","type":"string"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"registerInterChainAccount","outputs":[],"stateMutability":"nonpayable","type":"function"}] -------------------------------------------------------------------------------- /docs/precompiles/InterTx/InterTxInterface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | /// @title A precompile for sending transactions to the Golden Gate Bridge and nBridge 6 | /// @author The Laurel Project 7 | /// @notice It needs at least 2 (or even more for nBridge) chains and an IBC connection between them 8 | /// @dev Technical demos https://www.youtube.com/watch?v=ayFzY4btFX4&list=PL323JufuD9JBvmyqYtYLSe-xSSdJS9NPO 9 | /// custom:license This is covered by The Moral Licence - that is more strict than GPL-3.0 10 | interface InterTxPrecompile { 11 | 12 | // emitTx will send the `data` to the chain that corresponds to the `connectionId`. 13 | // The message will carry `value` and will be signed by `signature`. 14 | /// @notice Sends a transaction 15 | /// @dev Demoed at https://www.youtube.com/watch?v=I7zYXEtMeD4 16 | /// @param to Address of the contract that will execute the transaction 17 | /// @param from Address of the sender 18 | /// @param value The value in Wei sent to the transaction 19 | /// @param gasLimit The maximum of gas that can be used 20 | /// @param data The calldata or transaction input 21 | /// @param connectionId The ID of the IBC connection 22 | /// @param chainId The ID of the targeted chain 23 | /// @param signature is 65 bytes in length and is further composed 1B + 32B + 32B (v, s, r). 24 | /// @return response The response bytes 25 | /// @return error The error bytes 26 | function emitTx( 27 | address to, 28 | address from, // removed when signature works 29 | uint256 value, 30 | uint256 gasLimit, 31 | bytes memory data, 32 | string memory connectionId, 33 | uint256 chainId, 34 | bytes memory signature 35 | ) external returns( 36 | bytes memory response, 37 | bytes memory error 38 | ); 39 | 40 | /// @notice Sends a dependent transaction 41 | /// @dev Demoed at https://www.youtube.com/watch?v=I7zYXEtMeD4 42 | /// @param to Address of the contract that will execute the transaction 43 | /// @param from Address of the sender 44 | /// @param value The value in Wei sent to the transaction 45 | /// @param gasLimit The maximum of gas that can be used 46 | /// @param data The calldata or transaction input 47 | /// @param connectionId The ID of the IBC connection 48 | /// @param chainId The ID of the targeted chain 49 | /// @param signature is 65 bytes in length and is further composed 1B + 32B + 32B (v, s, r). 50 | /// @return response The response bytes 51 | /// @return error The error bytes 52 | function emitDependentTx( 53 | address to, 54 | address from, // removed when signature works 55 | uint256 value, 56 | uint256 gasLimit, 57 | bytes memory data, 58 | string memory connectionId, 59 | uint256 chainId, 60 | bytes memory signature 61 | ) external returns( 62 | bytes memory response, 63 | bytes memory error 64 | ); 65 | 66 | 67 | /// @notice Sends a multi-chain transaction (sed only by the nBridge) 68 | /// @dev Demoed at hhttps://www.youtube.com/watch?v=12FU9iG1D08&list=PL323JufuD9JBvmyqYtYLSe-xSSdJS9NPO&index=3 69 | /// @param to Address of the contract that will execute the transaction 70 | /// @param from Address of the sender 71 | /// @param value The value in Wei sent to the transaction 72 | /// @param gasLimit The maximum of gas that can be used 73 | /// @param data The calldata or transaction input 74 | /// @param chainIdentifiers The IDs as a bit mapping to single out the chains where the transaction should be replayed. The chainIDs being the bit location of the set bits 75 | /// @param signature is 65 bytes in length and is further composed 1B + 32B + 32B (v, s, r). 76 | /// @return response The response bytes 77 | /// @return error The error bytes 78 | function emitTxMulti( 79 | address to, 80 | address from, // removed when signature works 81 | uint256 value, 82 | uint256 gasLimit, 83 | bytes memory data, 84 | uint256 chainIdentifiers, 85 | bytes memory signature 86 | ) external returns( 87 | bytes memory response, 88 | bytes memory error 89 | ); 90 | 91 | /// @notice Creation of new interchain account 92 | /// @param owner Owner of the inter-chain account 93 | /// @param connectionId Connection id for the IBC channel 94 | /// @param signature For 3rd party registration of accounts, users must provide signature 95 | function registerInterChainAccount(address owner, string memory connectionId, bytes memory signature) external; 96 | 97 | /// @notice Retrieval of interchain account address 98 | /// @param owner Owner of the inter-chain account 99 | /// @param connectionId Connection id for the IBC channel 100 | function getInterChainAccountAddress(address owner, string memory connectionId) view external returns(string memory icaAddress); 101 | } 102 | -------------------------------------------------------------------------------- /docs/precompiles/PrecompileWrap.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | /// @title A precompiles bundle 6 | /// @author The Laurel Project 7 | /// @notice 4 precompiles 8 | /// @dev Technical demos are at https://www.youtube.com/c/LoredanaCirstea/videos 9 | /// custom:license This is covered by The Moral Licence - that is more strict than GPL-3.0 10 | contract PrecompileWrap { 11 | address public AbstractAccountAddress = 0x000000000000000000000000000000000000001a; 12 | address public InterTxAddress = 0x0000000000000000000000000000000000000019; 13 | address public CosmosSdkAddress = 0x000000000000000000000000000000000000001D; 14 | address public EvmInterpreterAddress = 0x0000000000000000000000000000000000000014; 15 | 16 | function callPrecompile(address precompileAddress, bytes memory payload, string memory err) internal returns(bytes memory) { 17 | (bool success, bytes memory data) = precompileAddress.call(payload); 18 | if (!success) revert(err); 19 | return abi.decode(data, (bytes)); 20 | } 21 | 22 | function staticcallPrecompile(address precompileAddress, bytes memory payload, string memory err) internal view returns(bytes memory) { 23 | (bool success, bytes memory data) = precompileAddress.staticcall(payload); 24 | if (!success) revert(err); 25 | return abi.decode(data, (bytes)); 26 | } 27 | 28 | // AbstractAccount 29 | 30 | /// @notice Sends a transaction as from an EOA 31 | /// @param signature is 65 bytes in length and is further composed 1B + 32B + 32B (v, s, r). 32 | function aa_sendTx( 33 | address to, 34 | address from, // removed when signature works 35 | uint256 value, 36 | uint256 gasLimit, 37 | bytes memory data, 38 | bytes memory signature 39 | ) external { 40 | bytes memory payload = abi.encodeWithSignature( 41 | "sendTx(address,address,uint256,uint256,bytes,bytes)", 42 | to, from, value, gasLimit, data, signature 43 | ); 44 | callPrecompile(AbstractAccountAddress, payload, "aa_sendTx failed"); 45 | } 46 | 47 | /// @notice Retrieval of abstract account address by owner 48 | function aa_getAccountAddress(address owner) view external returns (address account) { 49 | bytes memory payload = abi.encodeWithSignature( 50 | "getAccountAddress(address)", 51 | owner 52 | ); 53 | bytes memory res = staticcallPrecompile(AbstractAccountAddress, payload, "aa_getAccountAddress failed"); 54 | return abi.decode(res, (address)); 55 | } 56 | 57 | /// @notice Retrieval of abstract account by owner and IBC channel connectionId 58 | function aa_getAccount(address owner, string memory connectionId) view external returns (address accountAddress, uint256 nonce) { 59 | bytes memory payload = abi.encodeWithSignature( 60 | "getAccount(address,string)", 61 | owner, connectionId 62 | ); 63 | bytes memory res = staticcallPrecompile(AbstractAccountAddress, payload, "aa_getAccount failed"); 64 | return abi.decode(res, (address, uint256)); 65 | } 66 | 67 | /// @notice Creation of new abstract accounts 68 | function aa_registerAccount() external returns(address accountAddress){ 69 | bytes memory payload = abi.encodeWithSignature( 70 | "registerAccount()" 71 | ); 72 | bytes memory res = callPrecompile(AbstractAccountAddress, payload, "aa_registerAccount failed"); 73 | return abi.decode(res, (address)); 74 | } 75 | 76 | // CosmosSdkPrecompile 77 | 78 | /// @notice Sends a message from EVM to Cosmos 79 | /// @param msgType Type of message 80 | /// @param cosmosMsg Content of message 81 | /// @param signature is 65 bytes in length and is further composed 1B + 32B + 32B (v, s, r). 82 | function cosmos_sendMsg( 83 | string memory msgType, 84 | bytes memory cosmosMsg, 85 | bytes memory signature 86 | ) external { // TODO return 87 | bytes memory payload = abi.encodeWithSignature( 88 | "sendMsg(string,bytes,bytes)", 89 | msgType, cosmosMsg, signature 90 | ); 91 | callPrecompile(CosmosSdkAddress, payload, "cosmos_sendMsg failed"); 92 | } 93 | 94 | // EvmInterpreter 95 | 96 | /// @notice Analyzes a fragment of bytecode 97 | /// @dev Demoed at https://www.youtube.com/watch?v=kHDxDiM5xvQ&list=PL323JufuD9JCE_pGDLHJN-wVBpCPc9Q1G&index=8 98 | /// @param bytecodeFrag Any legal EVM bytecode portion 99 | /// @param stack The EVM Stack configuration before this bytecode is executing 100 | /// @param gas The available gas in Wei 101 | /// @param value The value in Wei sent to the transaction 102 | /// @return pc The Pointer Counter - position of the execution in the bytecode 103 | /// @return reads Number of reads from storage executed 104 | /// @return writes Number of slot writes into storage 105 | /// @return calls Number of external (other) contract calls 106 | /// @return memsize How many bytes of memory had been used 107 | /// @return gasused How much gas is left 108 | /// @return stackOut The EVM Stack configuration after this bytecode is executing 109 | function evm_analyzeFrag( 110 | bytes memory bytecodeFrag, 111 | bytes32[] memory stack, 112 | uint256 gas, 113 | uint256 value 114 | ) view external returns ( 115 | uint256 pc, 116 | uint256 reads, 117 | uint256 writes, 118 | uint256 calls, 119 | uint256 memsize, 120 | uint256 gasused, 121 | bytes32[] memory stackOut 122 | ){ 123 | bytes memory payload = abi.encodeWithSignature( 124 | "analyzeFrag(bytes,bytes32[],uint256,uint256)", 125 | bytecodeFrag, stack, gas, value 126 | ); 127 | bytes memory res = staticcallPrecompile(EvmInterpreterAddress, payload, "evm_analyzeFrag failed"); 128 | return abi.decode(res, (uint256, uint256, uint256, uint256, uint256, uint256, bytes32[])); 129 | } 130 | 131 | /// @notice Analyzes a contract call 132 | /// @param bytecode Any legal EVM bytecode (for a presumtive contract) 133 | /// @param input The EVM transaction calldata (for that contract) 134 | /// @param gas The available gas in Wei 135 | /// @param value The value in Wei sent to the transaction 136 | /// @return pc The Pointer Counter - position of the execution in the bytecode 137 | /// @return reads Number of reads from storage executed 138 | /// @return writes Number of slot writes into storage 139 | /// @return calls Number of external (other) contract calls 140 | /// @return memsize How many bytes of memory had been used 141 | /// @return gasused How much gas is left 142 | /// @return output The call result 143 | function evm_analyze( 144 | bytes memory bytecode, 145 | bytes memory input, 146 | uint256 gas, 147 | uint256 value 148 | ) view external returns ( 149 | uint256 pc, 150 | uint256 reads, 151 | uint256 writes, 152 | uint256 calls, 153 | uint256 memsize, 154 | uint256 gasused, 155 | bytes memory output 156 | ){ 157 | bytes memory payload = abi.encodeWithSignature( 158 | "analyze(bytes,bytes,uint256,uint256)", 159 | bytecode, input, gas, value 160 | ); 161 | bytes memory res = staticcallPrecompile(EvmInterpreterAddress, payload, "evm_analyze failed"); 162 | return abi.decode(res, (uint256, uint256, uint256, uint256, uint256, uint256, bytes)); 163 | } 164 | 165 | /// @notice Executes (immutably) a contract call 166 | /// @param bytecode Any legal EVM bytecode (for a presumtive contract) 167 | /// @param input The EVM transaction calldata (for that contract) 168 | /// @param gas The available gas in Wei 169 | /// @param value The value in Wei sent to the transaction 170 | /// @return result The call result 171 | function evm_interpret( 172 | bytes memory bytecode, 173 | bytes memory input, 174 | uint256 gas, 175 | uint256 value 176 | ) view external returns ( 177 | bytes memory result 178 | ){ 179 | bytes memory payload = abi.encodeWithSignature( 180 | "interpret(bytes,bytes,uint256,uint256)", 181 | bytecode, input, gas, value 182 | ); 183 | bytes memory res = staticcallPrecompile(EvmInterpreterAddress, payload, "evm_interpret failed"); 184 | return abi.decode(res, (bytes)); 185 | } 186 | 187 | /// @notice Describes the side effects of a call 188 | /// @param readHashInitial Previous reads side effects (for chaining transactions) 189 | /// @param writeHashInitial Previous writes side effects (for chaining transactions) 190 | /// @param bytecode Any legal EVM bytecode (for a presumtive contract) 191 | /// @param input The EVM transaction calldata (for that contract) 192 | /// @param gas The available gas in Wei 193 | /// @param value The value in Wei sent to the transaction 194 | /// @return readHash The read hash after of the execution of this call 195 | /// @return writeHash The write hash after of the execution of this call 196 | /// @return result The call result 197 | function evm_part( 198 | bytes32 readHashInitial, 199 | bytes32[] memory writeHashInitial, 200 | bytes memory bytecode, 201 | bytes memory input, 202 | uint256 gas, 203 | uint256 value 204 | ) view external returns ( 205 | bytes32 readHash, 206 | bytes32[] memory writeHash, 207 | bytes memory result 208 | ){ 209 | bytes memory payload = abi.encodeWithSignature( 210 | "part(bytes32,bytes32[],bytes,bytes,uint256,uint256)", 211 | readHashInitial, writeHashInitial, bytecode, input, gas, value 212 | ); 213 | bytes memory res = staticcallPrecompile(EvmInterpreterAddress, payload, "evm_part failed"); 214 | return abi.decode(res, (bytes32, bytes32[], bytes)); 215 | } 216 | 217 | /// @notice Describes the side effects of executing a fragment of bytecode 218 | /// @param readHashInitial Previous reads side effects (for chaining transactions) 219 | /// @param writeHashInitial Previous writes side effects (for chaining transactions) 220 | /// @param bytecodeFrag Any legal EVM bytecode fragment 221 | /// @param stack The EVM Stack configuration before this bytecode is executing 222 | /// @param gas The available gas in Wei 223 | /// @param value The value in Wei sent to the transaction 224 | /// @return readHash The read hash after of the execution of this call 225 | /// @return writeHash The write hash after of the execution of this call 226 | /// @return stackOut The EVM Stack configuration after this bytecode is executing 227 | function evm_partFrag( 228 | bytes32 readHashInitial, 229 | bytes32[] memory writeHashInitial, 230 | bytes memory bytecodeFrag, 231 | bytes32[] memory stack, 232 | uint256 gas, 233 | uint256 value 234 | ) view external returns ( 235 | bytes32 readHash, 236 | bytes32[] memory writeHash, 237 | bytes32[] memory stackOut 238 | ){ 239 | bytes memory payload = abi.encodeWithSignature( 240 | "partFrag(bytes32,bytes32[],bytes,bytes32[],uint256,uint256)", 241 | readHashInitial, writeHashInitial, bytecodeFrag, stack, gas, value 242 | ); 243 | bytes memory res = staticcallPrecompile(EvmInterpreterAddress, payload, "evm_partFrag failed"); 244 | return abi.decode(res, (bytes32, bytes32[], bytes32[])); 245 | } 246 | 247 | // InterTxPrecompile 248 | 249 | // emitTx will send the `data` to the chain that corresponds to the `connectionId`. 250 | // The message will carry `value` and will be signed by `signature`. 251 | /// @notice Sends a transaction 252 | /// @dev Demoed at https://www.youtube.com/watch?v=I7zYXEtMeD4 253 | /// @param to Address of the contract that will execute the transaction 254 | /// @param from Address of the sender 255 | /// @param value The value in Wei sent to the transaction 256 | /// @param gasLimit The maximum of gas that can be used 257 | /// @param data The calldata or transaction input 258 | /// @param connectionId The ID of the IBC connection 259 | /// @param chainId The ID of the targeted chain 260 | /// @param signature is 65 bytes in length and is further composed 1B + 32B + 32B (v, s, r). 261 | function intertx_emitTx( 262 | address to, 263 | address from, // removed when signature works 264 | uint256 value, 265 | uint256 gasLimit, 266 | bytes memory data, 267 | string memory connectionId, 268 | uint256 chainId, 269 | bytes memory signature 270 | ) external { // TODO return 271 | bytes memory payload = abi.encodeWithSignature( 272 | "emitTx(address,address,uint256,uint256,bytes,string,uint256,bytes)", 273 | to, from, value, gasLimit, data, connectionId, chainId, signature 274 | ); 275 | callPrecompile(InterTxAddress, payload, "intertx_emitTx failed"); 276 | } 277 | 278 | /// @notice Sends a dependent transaction 279 | /// @dev Demoed at https://www.youtube.com/watch?v=I7zYXEtMeD4 280 | /// @param to Address of the contract that will execute the transaction 281 | /// @param from Address of the sender 282 | /// @param value The value in Wei sent to the transaction 283 | /// @param gasLimit The maximum of gas that can be used 284 | /// @param data The calldata or transaction input 285 | /// @param connectionId The ID of the IBC connection 286 | /// @param chainId The ID of the targeted chain 287 | /// @param signature is 65 bytes in length and is further composed 1B + 32B + 32B (v, s, r). 288 | function intertx_emitDependentTx( 289 | address to, 290 | address from, // removed when signature works 291 | uint256 value, 292 | uint256 gasLimit, 293 | bytes memory data, 294 | string memory connectionId, 295 | uint256 chainId, 296 | bytes memory signature 297 | ) external { // TODO return 298 | bytes memory payload = abi.encodeWithSignature( 299 | "emitDependentTx(address,address,uint256,uint256,bytes,string,uint256,bytes)", 300 | to, from, value, gasLimit, data, connectionId, chainId, signature 301 | ); 302 | callPrecompile(InterTxAddress, payload, "intertx_emitDependentTx failed"); 303 | } 304 | 305 | 306 | /// @notice Sends a multi-chain transaction (sed only by the nBridge) 307 | /// @dev Demoed at hhttps://www.youtube.com/watch?v=12FU9iG1D08&list=PL323JufuD9JBvmyqYtYLSe-xSSdJS9NPO&index=3 308 | /// @param to Address of the contract that will execute the transaction 309 | /// @param from Address of the sender 310 | /// @param value The value in Wei sent to the transaction 311 | /// @param gasLimit The maximum of gas that can be used 312 | /// @param data The calldata or transaction input 313 | /// @param chainIdentifiers The IDs as a bit mapping to single out the chains where the transaction should be replayed. The chainIDs being the bit location of the set bits 314 | /// @param signature is 65 bytes in length and is further composed 1B + 32B + 32B (v, s, r). 315 | function intertx_emitTxMulti( 316 | address to, 317 | address from, // removed when signature works 318 | uint256 value, 319 | uint256 gasLimit, 320 | bytes memory data, 321 | uint256 chainIdentifiers, 322 | bytes memory signature 323 | ) external { // TODO return 324 | bytes memory payload = abi.encodeWithSignature( 325 | "emitTxMulti(address,address,uint256,uint256,bytes,uint256,bytes)", 326 | to, from, value, gasLimit, data, chainIdentifiers, signature 327 | ); 328 | callPrecompile(InterTxAddress, payload, "intertx_emitTxMulti failed"); 329 | } 330 | 331 | /// @notice Creation of new interchain account 332 | /// @param owner Owner of the inter-chain account 333 | /// @param connectionId Connection id for the IBC channel 334 | /// @param signature For 3rd party registration of accounts, users must provide signature 335 | function intertx_registerInterChainAccount( 336 | address owner, string memory connectionId, bytes memory signature 337 | ) external { // TODO return 338 | bytes memory payload = abi.encodeWithSignature( 339 | "emitTxMulti(address,string,bytes)", 340 | owner, connectionId, signature 341 | ); 342 | callPrecompile(InterTxAddress, payload, "intertx_registerInterChainAccount failed"); 343 | } 344 | 345 | /// @notice Retrieval of interchain account address 346 | /// @param owner Owner of the inter-chain account 347 | /// @param connectionId Connection id for the IBC channel 348 | function intertx_getInterChainAccountAddress(address owner, string memory connectionId) view external returns(string memory icaAddress) { 349 | bytes memory payload = abi.encodeWithSignature( 350 | "getInterChainAccountAddress(address,string)", 351 | owner, connectionId 352 | ); 353 | bytes memory res = staticcallPrecompile(InterTxAddress, payload, "intertx_getInterChainAccountAddress failed"); 354 | return abi.decode(res, (string)); 355 | } 356 | } -------------------------------------------------------------------------------- /docs/precompiles/Quasar/CosmosSdkAbi.json: -------------------------------------------------------------------------------- 1 | [{"inputs":[{"internalType":"bytes","name":"msg","type":"bytes"}],"name":"sendMsgRaw","outputs":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"data","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"msg","type":"bytes"}],"name":"sendQueryRaw","outputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"stateMutability":"view","type":"function"}] 2 | -------------------------------------------------------------------------------- /docs/precompiles/Quasar/CosmosSdkInterface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | /// @title A precompile for sending transactions and messages to the Cosmos SDK 6 | /// @author The Laurel Project 7 | /// @notice It crosses execution engine bounds 8 | /// @dev Technical demos are about Quasar eg: https://www.youtube.com/watch?v=PlbAWUK54PU 9 | /// custom:license This is covered by The Moral Licence - that is more strict than GPL-3.0 10 | interface QuasarPrecompile { 11 | 12 | /// @notice Sends a message from EVM to Cosmos 13 | /// @param msg Cosmos message (binary encoding with Protobuf - ProtoCodec) 14 | /// @return success Execution was a success? 15 | /// @return data Content of result, encoded 16 | function sendMsgRaw( 17 | bytes memory msg 18 | ) external returns(bool success, bytes memory data); 19 | 20 | /// @notice Sends a query from EVM to Cosmos 21 | /// @param msg Cosmos query message (binary encoding with Protobuf - ProtoCodec) 22 | /// @return data Content of result 23 | function sendQueryRaw( 24 | bytes memory msg 25 | ) external view returns(bytes memory data); 26 | } 27 | -------------------------------------------------------------------------------- /docs/precompiles/Quasar/README.md: -------------------------------------------------------------------------------- 1 | # Quasar 2 | 3 | ## Demos 4 | 5 | [https://www.youtube.com/playlist?list=PL323JufuD9JB1R28TdzCtiiIwTHy9TX5C](https://www.youtube.com/playlist?list=PL323JufuD9JB1R28TdzCtiiIwTHy9TX5C) 6 | 7 | 8 | ## Test Quasar 9 | 10 | Register for tokens: https://docs.google.com/forms/d/e/1FAIpQLSebODebNu4eSVBGIY3EowXqHQTTaLAFngMiWHihVeKeHWuWYQ/viewform 11 | 12 | Join Mythos Discord for support: https://discord.gg/dp4DaVz8 13 | 14 | Add Mythos to Metamask: 15 | 16 | ``` 17 | Name: mythos.provable.dev 18 | RPC URL: https://mythos-evm.provable.dev 19 | ChainID: 7001 20 | Currency: MYT 21 | Block explorer: https://explorer-mythos.provable.dev/ 22 | ``` 23 | 24 | Cosmos explorer: https://explorer.provable.dev/ 25 | 26 | ### Quasar Precompile 27 | 28 | - address: `0x000000000000000000000000000000000000001D` 29 | - Solidity interface: [QuasarPrecompile interface](./CosmosSdkInterface.sol) 30 | - abi: [QuasarPrecompile abi](./CosmosSdkAbi.json) 31 | 32 | You can directly call the Quasar precompile as you would call any other contract. 33 | 34 | Or you can call it from another smart contract: 35 | * deploy the test contract [CosmosSdkProxyContract](./test/ProxyContract.sol) 36 | * a more complex example with nested calls is the [CallSelf contract](./test/RecursiveProxyContract.sol). This was used in this demo video: [Quasar is on Mythos. Execute Cosmos Transactions & Queries from the EVM. For any Ethermint chain.](https://youtu.be/COu5Olszhtg). Already deployed at [0x38f006F11fbD148B269c2098743396ba802B301c](https://explorer-mythos.provable.dev/address/0x38f006F11fbD148B269c2098743396ba802B301c). 37 | 38 | To easily encode your Cosmos messages (as shown in the above video), you can use: [https://mark.provable.dev/?ipfs=QmX81PMCPn8KgUehzperdH7DRxW7fYd9H1HrDkgkwstcKW](https://mark.provable.dev/?ipfs=QmX81PMCPn8KgUehzperdH7DRxW7fYd9H1HrDkgkwstcKW). 39 | 40 | Note!: Right now you cannot directly use the `QuasarPrecompile` interface to initialize contract instances in Solidity and send calls, because Solidity does a check on whether bytecode exists at the precompile address (the precompile is a native contract, without bytecode, so this check fails). This is why you need to use a lower-level `call`. This will be mitigated in the near future. 41 | 42 | ### sendMsgRaw 43 | 44 | ### sendQueryRaw 45 | 46 | ### sendMsgAbiEncoded 47 | 48 | Coming soon 49 | 50 | ### sendQueryAbiEncoded 51 | 52 | Coming soon 53 | 54 | ### Protobuf-Encoding as a Solidity library 55 | 56 | Coming soon 57 | -------------------------------------------------------------------------------- /docs/precompiles/Quasar/test/ProxyContract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract CosmosSdkProxyContract { 6 | address public CosmosSdkAddress = 0x000000000000000000000000000000000000001D; 7 | 8 | function sendMsgRaw(bytes memory encodedMsg) public returns(bool success, bytes memory data) { 9 | bytes memory payload = abi.encodeWithSignature("sendMsgRaw(bytes)", encodedMsg); 10 | 11 | (bool _success, bytes memory _data) = CosmosSdkAddress.call(payload); 12 | if (!_success) revert("Quasar precompile tx failed"); 13 | return (_success, _data); 14 | } 15 | 16 | function sendMsgRawNoRevert(bytes memory encodedMsg) public returns(bool success, bytes memory data) { 17 | bytes memory payload = abi.encodeWithSignature("sendMsgRaw(bytes)", encodedMsg); 18 | 19 | (bool _success, bytes memory _data) = CosmosSdkAddress.call(payload); 20 | return (_success, _data); 21 | } 22 | 23 | function sendMsgRawDelegate(bytes memory encodedMsg) public returns(bool success, bytes memory data) { 24 | bytes memory payload = abi.encodeWithSignature("sendMsgRaw(bytes)", encodedMsg); 25 | 26 | (bool _success, bytes memory _data) = CosmosSdkAddress.delegatecall(payload); 27 | if (!_success) revert("Quasar precompile tx failed"); 28 | return (_success, _data); 29 | } 30 | 31 | function sendMsgRawStatic(bytes memory encodedMsg) view public returns(bool success, bytes memory data) { 32 | bytes memory payload = abi.encodeWithSignature("sendMsgRaw(bytes)", encodedMsg); 33 | 34 | (bool _success, bytes memory _data) = CosmosSdkAddress.staticcall(payload); 35 | if (!_success) revert("Quasar precompile tx failed"); 36 | return (_success, _data); 37 | } 38 | 39 | function sendQueryRaw(bytes memory encodedMsg) view public returns(bytes memory data) { 40 | bytes memory payload = abi.encodeWithSignature("sendQueryRaw(bytes)", encodedMsg); 41 | 42 | (bool _success, bytes memory _data) = CosmosSdkAddress.staticcall(payload); 43 | if (!_success) revert("Quasar precompile query failed"); 44 | return _data; 45 | } 46 | 47 | function sendMsgRawRevert(bytes memory encodedMsg) public { 48 | bytes memory payload = abi.encodeWithSignature("sendMsgRaw(bytes)", encodedMsg); 49 | 50 | (bool _success, bytes memory _data) = CosmosSdkAddress.call(payload); 51 | if (!_success) revert("Quasar precompile query failed"); 52 | 53 | revert("reverted after quasar call concluded: "); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /docs/precompiles/Quasar/test/RecursiveProxyContract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract CallSelf { 6 | 7 | struct CallInfo { 8 | address recipient; 9 | address contractAddress; 10 | bytes data; 11 | } 12 | 13 | event GasAvailable(uint256 indexed gas); 14 | event Context(bool indexed postcall, uint256 indexed contractBalance, uint256 indexed accountBalance); 15 | event InnerCallResult(uint256 indexed index, bool indexed success); 16 | 17 | receive() external payable {} 18 | constructor() payable {} 19 | 20 | function callself(uint256 n) public { 21 | if (n > 0) { 22 | callself(n - 1); 23 | } 24 | } 25 | 26 | function callselfWithInnerCall(CallInfo[] memory callInfos) public { 27 | if (callInfos.length == 0) {return;} 28 | 29 | // We modify the balance in the EVM, prior to the precompile call 30 | payable(callInfos[0].recipient).transfer(7777); 31 | 32 | emit Context(false, address(this).balance, callInfos[0].recipient.balance); 33 | 34 | uint256 gasAvailable; 35 | assembly { 36 | gasAvailable := gas() 37 | } 38 | 39 | emit GasAvailable(gasAvailable - 750); // 375 log + 375 topic 40 | 41 | // execute the call 42 | (bool success, ) = callInfos[0].contractAddress.call(callInfos[0].data); 43 | 44 | assembly { 45 | gasAvailable := gas() 46 | } 47 | 48 | emit GasAvailable(gasAvailable); 49 | emit Context(true, address(this).balance, callInfos[0].recipient.balance); 50 | emit InnerCallResult(1, success); 51 | 52 | // execute a second call 53 | (bool success2, ) = callInfos[1].contractAddress.call(callInfos[1].data); 54 | require(success2, "second inner call failed"); 55 | 56 | emit Context(true, address(this).balance, callInfos[1].recipient.balance); 57 | emit InnerCallResult(2, success2); 58 | 59 | 60 | uint256 newlen = callInfos.length - 2; 61 | CallInfo[] memory _callInfos = new CallInfo[](newlen); 62 | for (uint i = 2; i < callInfos.length; i++) { 63 | _callInfos[i - 2] = callInfos[i]; 64 | } 65 | 66 | (bool success3, ) = address(this).call( 67 | abi.encodeWithSignature("callselfWithInnerCall((address,address,bytes)[])", _callInfos) 68 | ); 69 | emit InnerCallResult(3, success3); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /multi-chain-simple-storage/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-laurel/demos/ac373fb65ae142be47bb8399bede40122b7ef5ab/multi-chain-simple-storage/README.md -------------------------------------------------------------------------------- /multi-chain-simple-storage/SimpleStorage.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | /** 6 | * @title Storage 7 | * @dev Store & retrieve value in a variable 8 | * @custom:dev-run-script ./scripts/deploy_with_ethers.ts 9 | */ 10 | contract Storage { 11 | 12 | uint256 number = 5; 13 | 14 | /** 15 | * @dev Store value in variable 16 | * @param num value to store 17 | */ 18 | function set(uint256 num) public { 19 | number = num; 20 | } 21 | 22 | /** 23 | * @dev Return value 24 | * @return value of 'number' 25 | */ 26 | function get() public view returns (uint256){ 27 | return number; 28 | } 29 | } -------------------------------------------------------------------------------- /multi-chain-simple-storage/SimpleStorageAbi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "get", 5 | "outputs": [ 6 | { 7 | "internalType": "uint256", 8 | "name": "", 9 | "type": "uint256" 10 | } 11 | ], 12 | "stateMutability": "view", 13 | "type": "function" 14 | }, 15 | { 16 | "inputs": [ 17 | { 18 | "internalType": "uint256", 19 | "name": "num", 20 | "type": "uint256" 21 | } 22 | ], 23 | "name": "set", 24 | "outputs": [], 25 | "stateMutability": "nonpayable", 26 | "type": "function" 27 | } 28 | ] -------------------------------------------------------------------------------- /multi-chain-simple-storage/SimpleStorageMark.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain": 7001, 3 | "contracts": [ 4 | { 5 | "name": "ProxyBridge", 6 | "address": "0xdc0CEFCA29dD23c529628d5BB62cC92f72C89336", 7 | "ipfs": "QmchGTwvYzdB1VrD3zZ392frQPJhbQHmvNfYpkQPfmHTcP", 8 | "abi": [ 9 | { 10 | "anonymous": false, 11 | "inputs": [ 12 | { 13 | "indexed": true, 14 | "internalType": "address", 15 | "name": "from", 16 | "type": "address" 17 | }, 18 | { 19 | "indexed": true, 20 | "internalType": "address", 21 | "name": "to", 22 | "type": "address" 23 | }, 24 | { 25 | "indexed": false, 26 | "internalType": "bytes", 27 | "name": "result", 28 | "type": "bytes" 29 | } 30 | ], 31 | "name": "EmitResult", 32 | "type": "event" 33 | }, 34 | { 35 | "inputs": [], 36 | "name": "AbstractAccountsAddress", 37 | "outputs": [ 38 | { 39 | "internalType": "address", 40 | "name": "", 41 | "type": "address" 42 | } 43 | ], 44 | "stateMutability": "view", 45 | "type": "function" 46 | }, 47 | { 48 | "inputs": [], 49 | "name": "IcaAddress", 50 | "outputs": [ 51 | { 52 | "internalType": "address", 53 | "name": "", 54 | "type": "address" 55 | } 56 | ], 57 | "stateMutability": "view", 58 | "type": "function" 59 | }, 60 | { 61 | "inputs": [], 62 | "name": "balance", 63 | "outputs": [ 64 | { 65 | "internalType": "uint256", 66 | "name": "", 67 | "type": "uint256" 68 | } 69 | ], 70 | "stateMutability": "view", 71 | "type": "function" 72 | }, 73 | { 74 | "inputs": [ 75 | { 76 | "internalType": "address", 77 | "name": "to", 78 | "type": "address" 79 | }, 80 | { 81 | "internalType": "uint256", 82 | "name": "value", 83 | "type": "uint256" 84 | }, 85 | { 86 | "internalType": "uint256", 87 | "name": "gasLimit", 88 | "type": "uint256" 89 | }, 90 | { 91 | "internalType": "bytes", 92 | "name": "calld", 93 | "type": "bytes" 94 | }, 95 | { 96 | "internalType": "string", 97 | "name": "connectionId", 98 | "type": "string" 99 | }, 100 | { 101 | "internalType": "uint256", 102 | "name": "chainId", 103 | "type": "uint256" 104 | }, 105 | { 106 | "internalType": "bytes", 107 | "name": "signature", 108 | "type": "bytes" 109 | } 110 | ], 111 | "name": "replay", 112 | "outputs": [], 113 | "stateMutability": "nonpayable", 114 | "type": "function" 115 | }, 116 | { 117 | "inputs": [ 118 | { 119 | "internalType": "address", 120 | "name": "to", 121 | "type": "address" 122 | }, 123 | { 124 | "internalType": "uint256", 125 | "name": "value", 126 | "type": "uint256" 127 | }, 128 | { 129 | "internalType": "uint256", 130 | "name": "gasLimit", 131 | "type": "uint256" 132 | }, 133 | { 134 | "internalType": "bytes", 135 | "name": "calld", 136 | "type": "bytes" 137 | }, 138 | { 139 | "internalType": "uint256", 140 | "name": "chainIdentifiers", 141 | "type": "uint256" 142 | }, 143 | { 144 | "internalType": "bytes", 145 | "name": "signature", 146 | "type": "bytes" 147 | } 148 | ], 149 | "name": "replayMulti", 150 | "outputs": [], 151 | "stateMutability": "nonpayable", 152 | "type": "function" 153 | }, 154 | { 155 | "stateMutability": "payable", 156 | "type": "receive" 157 | } 158 | ] 159 | } 160 | ], 161 | "content": "# The nBridge - A Golden Gate Bridge Application\n\n## mythos_7001-1\n\n\n\n\n\n## Deploy Inter-Chain Contract\n\n\n\n\n\n\n\n:br[]\n\n## Deployed Contract\n\n\n\n:br[]\n", 162 | "manual": null 163 | } -------------------------------------------------------------------------------- /nBridge/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-laurel/demos/ac373fb65ae142be47bb8399bede40122b7ef5ab/nBridge/README.md -------------------------------------------------------------------------------- /nBridge/nBridgeMark.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain": 7001, 3 | "contracts": [ 4 | { 5 | "name": "ProxyBridge", 6 | "address": "0xdc0CEFCA29dD23c529628d5BB62cC92f72C89336", 7 | "ipfs": "QmchGTwvYzdB1VrD3zZ392frQPJhbQHmvNfYpkQPfmHTcP", 8 | "abi": [ 9 | { 10 | "anonymous": false, 11 | "inputs": [ 12 | { 13 | "indexed": true, 14 | "internalType": "address", 15 | "name": "from", 16 | "type": "address" 17 | }, 18 | { 19 | "indexed": true, 20 | "internalType": "address", 21 | "name": "to", 22 | "type": "address" 23 | }, 24 | { 25 | "indexed": false, 26 | "internalType": "bytes", 27 | "name": "result", 28 | "type": "bytes" 29 | } 30 | ], 31 | "name": "EmitResult", 32 | "type": "event" 33 | }, 34 | { 35 | "inputs": [], 36 | "name": "AbstractAccountsAddress", 37 | "outputs": [ 38 | { 39 | "internalType": "address", 40 | "name": "", 41 | "type": "address" 42 | } 43 | ], 44 | "stateMutability": "view", 45 | "type": "function" 46 | }, 47 | { 48 | "inputs": [], 49 | "name": "IcaAddress", 50 | "outputs": [ 51 | { 52 | "internalType": "address", 53 | "name": "", 54 | "type": "address" 55 | } 56 | ], 57 | "stateMutability": "view", 58 | "type": "function" 59 | }, 60 | { 61 | "inputs": [], 62 | "name": "balance", 63 | "outputs": [ 64 | { 65 | "internalType": "uint256", 66 | "name": "", 67 | "type": "uint256" 68 | } 69 | ], 70 | "stateMutability": "view", 71 | "type": "function" 72 | }, 73 | { 74 | "inputs": [ 75 | { 76 | "internalType": "address", 77 | "name": "to", 78 | "type": "address" 79 | }, 80 | { 81 | "internalType": "uint256", 82 | "name": "value", 83 | "type": "uint256" 84 | }, 85 | { 86 | "internalType": "uint256", 87 | "name": "gasLimit", 88 | "type": "uint256" 89 | }, 90 | { 91 | "internalType": "bytes", 92 | "name": "calld", 93 | "type": "bytes" 94 | }, 95 | { 96 | "internalType": "string", 97 | "name": "connectionId", 98 | "type": "string" 99 | }, 100 | { 101 | "internalType": "uint256", 102 | "name": "chainId", 103 | "type": "uint256" 104 | }, 105 | { 106 | "internalType": "bytes", 107 | "name": "signature", 108 | "type": "bytes" 109 | } 110 | ], 111 | "name": "replay", 112 | "outputs": [], 113 | "stateMutability": "nonpayable", 114 | "type": "function" 115 | }, 116 | { 117 | "inputs": [ 118 | { 119 | "internalType": "address", 120 | "name": "to", 121 | "type": "address" 122 | }, 123 | { 124 | "internalType": "uint256", 125 | "name": "value", 126 | "type": "uint256" 127 | }, 128 | { 129 | "internalType": "uint256", 130 | "name": "gasLimit", 131 | "type": "uint256" 132 | }, 133 | { 134 | "internalType": "bytes", 135 | "name": "calld", 136 | "type": "bytes" 137 | }, 138 | { 139 | "internalType": "uint256", 140 | "name": "chainIdentifiers", 141 | "type": "uint256" 142 | }, 143 | { 144 | "internalType": "bytes", 145 | "name": "signature", 146 | "type": "bytes" 147 | } 148 | ], 149 | "name": "replayMulti", 150 | "outputs": [], 151 | "stateMutability": "nonpayable", 152 | "type": "function" 153 | }, 154 | { 155 | "stateMutability": "payable", 156 | "type": "receive" 157 | } 158 | ] 159 | } 160 | ], 161 | "content": "# The nBridge - A Golden Gate Bridge Application\n\n_( ! You need to be connected to Mythos (chainId 7001) to use this dApp )_\n\n\n\n\n\n\n\n## Deploy Inter-Chain Contract\n\n\n\n\n\n\n\n\n\n:br[]\n\n## Deployed Contract\n\n\n\n:br[]\n", 162 | "manual": null 163 | } --------------------------------------------------------------------------------