├── README.md └── caw.sol /README.md: -------------------------------------------------------------------------------- 1 | # contract 2 | Deployed at ... 0xf3b9569F82B18aEf890De263B84189bd33EBe452 3 | -------------------------------------------------------------------------------- /caw.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | // File: @openzeppelin/contracts/token/ERC20/IERC20.sol 4 | 5 | 6 | // OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol) 7 | 8 | pragma solidity ^0.8.0; 9 | 10 | /** 11 | * @dev Interface of the ERC20 standard as defined in the EIP. 12 | */ 13 | interface IERC20 { 14 | /** 15 | * @dev Returns the amount of tokens in existence. 16 | */ 17 | function totalSupply() external view returns (uint256); 18 | 19 | /** 20 | * @dev Returns the amount of tokens owned by `account`. 21 | */ 22 | function balanceOf(address account) external view returns (uint256); 23 | 24 | /** 25 | * @dev Moves `amount` tokens from the caller's account to `recipient`. 26 | * 27 | * Returns a boolean value indicating whether the operation succeeded. 28 | * 29 | * Emits a {Transfer} event. 30 | */ 31 | function transfer(address recipient, uint256 amount) external returns (bool); 32 | 33 | /** 34 | * @dev Returns the remaining number of tokens that `spender` will be 35 | * allowed to spend on behalf of `owner` through {transferFrom}. This is 36 | * zero by default. 37 | * 38 | * This value changes when {approve} or {transferFrom} are called. 39 | */ 40 | function allowance(address owner, address spender) external view returns (uint256); 41 | 42 | /** 43 | * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. 44 | * 45 | * Returns a boolean value indicating whether the operation succeeded. 46 | * 47 | * IMPORTANT: Beware that changing an allowance with this method brings the risk 48 | * that someone may use both the old and the new allowance by unfortunate 49 | * transaction ordering. One possible solution to mitigate this race 50 | * condition is to first reduce the spender's allowance to 0 and set the 51 | * desired value afterwards: 52 | * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 53 | * 54 | * Emits an {Approval} event. 55 | */ 56 | function approve(address spender, uint256 amount) external returns (bool); 57 | 58 | /** 59 | * @dev Moves `amount` tokens from `sender` to `recipient` using the 60 | * allowance mechanism. `amount` is then deducted from the caller's 61 | * allowance. 62 | * 63 | * Returns a boolean value indicating whether the operation succeeded. 64 | * 65 | * Emits a {Transfer} event. 66 | */ 67 | function transferFrom( 68 | address sender, 69 | address recipient, 70 | uint256 amount 71 | ) external returns (bool); 72 | 73 | /** 74 | * @dev Emitted when `value` tokens are moved from one account (`from`) to 75 | * another (`to`). 76 | * 77 | * Note that `value` may be zero. 78 | */ 79 | event Transfer(address indexed from, address indexed to, uint256 value); 80 | 81 | /** 82 | * @dev Emitted when the allowance of a `spender` for an `owner` is set by 83 | * a call to {approve}. `value` is the new allowance. 84 | */ 85 | event Approval(address indexed owner, address indexed spender, uint256 value); 86 | } 87 | 88 | // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol 89 | 90 | 91 | // OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/IERC20Metadata.sol) 92 | 93 | pragma solidity ^0.8.0; 94 | 95 | 96 | /** 97 | * @dev Interface for the optional metadata functions from the ERC20 standard. 98 | * 99 | * _Available since v4.1._ 100 | */ 101 | interface IERC20Metadata is IERC20 { 102 | /** 103 | * @dev Returns the name of the token. 104 | */ 105 | function name() external view returns (string memory); 106 | 107 | /** 108 | * @dev Returns the symbol of the token. 109 | */ 110 | function symbol() external view returns (string memory); 111 | 112 | /** 113 | * @dev Returns the decimals places of the token. 114 | */ 115 | function decimals() external view returns (uint8); 116 | } 117 | 118 | // File: @openzeppelin/contracts/utils/Context.sol 119 | 120 | 121 | // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) 122 | 123 | pragma solidity ^0.8.0; 124 | 125 | /** 126 | * @dev Provides information about the current execution context, including the 127 | * sender of the transaction and its data. While these are generally available 128 | * via msg.sender and msg.data, they should not be accessed in such a direct 129 | * manner, since when dealing with meta-transactions the account sending and 130 | * paying for execution may not be the actual sender (as far as an application 131 | * is concerned). 132 | * 133 | * This contract is only required for intermediate, library-like contracts. 134 | */ 135 | abstract contract Context { 136 | function _msgSender() internal view virtual returns (address) { 137 | return msg.sender; 138 | } 139 | 140 | function _msgData() internal view virtual returns (bytes calldata) { 141 | return msg.data; 142 | } 143 | } 144 | 145 | // File: @openzeppelin/contracts/token/ERC20/ERC20.sol 146 | 147 | 148 | // OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol) 149 | 150 | pragma solidity ^0.8.0; 151 | 152 | 153 | 154 | 155 | /** 156 | * @dev Implementation of the {IERC20} interface. 157 | * 158 | * This implementation is agnostic to the way tokens are created. This means 159 | * that a supply mechanism has to be added in a derived contract using {_mint}. 160 | * For a generic mechanism see {ERC20PresetMinterPauser}. 161 | * 162 | * TIP: For a detailed writeup see our guide 163 | * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How 164 | * to implement supply mechanisms]. 165 | * 166 | * We have followed general OpenZeppelin Contracts guidelines: functions revert 167 | * instead returning `false` on failure. This behavior is nonetheless 168 | * conventional and does not conflict with the expectations of ERC20 169 | * applications. 170 | * 171 | * Additionally, an {Approval} event is emitted on calls to {transferFrom}. 172 | * This allows applications to reconstruct the allowance for all accounts just 173 | * by listening to said events. Other implementations of the EIP may not emit 174 | * these events, as it isn't required by the specification. 175 | * 176 | * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} 177 | * functions have been added to mitigate the well-known issues around setting 178 | * allowances. See {IERC20-approve}. 179 | */ 180 | contract ERC20 is Context, IERC20, IERC20Metadata { 181 | mapping(address => uint256) private _balances; 182 | 183 | mapping(address => mapping(address => uint256)) private _allowances; 184 | 185 | uint256 private _totalSupply; 186 | 187 | string private _name; 188 | string private _symbol; 189 | 190 | /** 191 | * @dev Sets the values for {name} and {symbol}. 192 | * 193 | * The default value of {decimals} is 18. To select a different value for 194 | * {decimals} you should overload it. 195 | * 196 | * All two of these values are immutable: they can only be set once during 197 | * construction. 198 | */ 199 | constructor(string memory name_, string memory symbol_) { 200 | _name = name_; 201 | _symbol = symbol_; 202 | } 203 | 204 | /** 205 | * @dev Returns the name of the token. 206 | */ 207 | function name() public view virtual override returns (string memory) { 208 | return _name; 209 | } 210 | 211 | /** 212 | * @dev Returns the symbol of the token, usually a shorter version of the 213 | * name. 214 | */ 215 | function symbol() public view virtual override returns (string memory) { 216 | return _symbol; 217 | } 218 | 219 | /** 220 | * @dev Returns the number of decimals used to get its user representation. 221 | * For example, if `decimals` equals `2`, a balance of `505` tokens should 222 | * be displayed to a user as `5.05` (`505 / 10 ** 2`). 223 | * 224 | * Tokens usually opt for a value of 18, imitating the relationship between 225 | * Ether and Wei. This is the value {ERC20} uses, unless this function is 226 | * overridden; 227 | * 228 | * NOTE: This information is only used for _display_ purposes: it in 229 | * no way affects any of the arithmetic of the contract, including 230 | * {IERC20-balanceOf} and {IERC20-transfer}. 231 | */ 232 | function decimals() public view virtual override returns (uint8) { 233 | return 18; 234 | } 235 | 236 | /** 237 | * @dev See {IERC20-totalSupply}. 238 | */ 239 | function totalSupply() public view virtual override returns (uint256) { 240 | return _totalSupply; 241 | } 242 | 243 | /** 244 | * @dev See {IERC20-balanceOf}. 245 | */ 246 | function balanceOf(address account) public view virtual override returns (uint256) { 247 | return _balances[account]; 248 | } 249 | 250 | /** 251 | * @dev See {IERC20-transfer}. 252 | * 253 | * Requirements: 254 | * 255 | * - `recipient` cannot be the zero address. 256 | * - the caller must have a balance of at least `amount`. 257 | */ 258 | function transfer(address recipient, uint256 amount) public virtual override returns (bool) { 259 | _transfer(_msgSender(), recipient, amount); 260 | return true; 261 | } 262 | 263 | /** 264 | * @dev See {IERC20-allowance}. 265 | */ 266 | function allowance(address owner, address spender) public view virtual override returns (uint256) { 267 | return _allowances[owner][spender]; 268 | } 269 | 270 | /** 271 | * @dev See {IERC20-approve}. 272 | * 273 | * Requirements: 274 | * 275 | * - `spender` cannot be the zero address. 276 | */ 277 | function approve(address spender, uint256 amount) public virtual override returns (bool) { 278 | _approve(_msgSender(), spender, amount); 279 | return true; 280 | } 281 | 282 | /** 283 | * @dev See {IERC20-transferFrom}. 284 | * 285 | * Emits an {Approval} event indicating the updated allowance. This is not 286 | * required by the EIP. See the note at the beginning of {ERC20}. 287 | * 288 | * Requirements: 289 | * 290 | * - `sender` and `recipient` cannot be the zero address. 291 | * - `sender` must have a balance of at least `amount`. 292 | * - the caller must have allowance for ``sender``'s tokens of at least 293 | * `amount`. 294 | */ 295 | function transferFrom( 296 | address sender, 297 | address recipient, 298 | uint256 amount 299 | ) public virtual override returns (bool) { 300 | _transfer(sender, recipient, amount); 301 | 302 | uint256 currentAllowance = _allowances[sender][_msgSender()]; 303 | require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); 304 | unchecked { 305 | _approve(sender, _msgSender(), currentAllowance - amount); 306 | } 307 | 308 | return true; 309 | } 310 | 311 | /** 312 | * @dev Atomically increases the allowance granted to `spender` by the caller. 313 | * 314 | * This is an alternative to {approve} that can be used as a mitigation for 315 | * problems described in {IERC20-approve}. 316 | * 317 | * Emits an {Approval} event indicating the updated allowance. 318 | * 319 | * Requirements: 320 | * 321 | * - `spender` cannot be the zero address. 322 | */ 323 | function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { 324 | _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); 325 | return true; 326 | } 327 | 328 | /** 329 | * @dev Atomically decreases the allowance granted to `spender` by the caller. 330 | * 331 | * This is an alternative to {approve} that can be used as a mitigation for 332 | * problems described in {IERC20-approve}. 333 | * 334 | * Emits an {Approval} event indicating the updated allowance. 335 | * 336 | * Requirements: 337 | * 338 | * - `spender` cannot be the zero address. 339 | * - `spender` must have allowance for the caller of at least 340 | * `subtractedValue`. 341 | */ 342 | function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { 343 | uint256 currentAllowance = _allowances[_msgSender()][spender]; 344 | require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); 345 | unchecked { 346 | _approve(_msgSender(), spender, currentAllowance - subtractedValue); 347 | } 348 | 349 | return true; 350 | } 351 | 352 | /** 353 | * @dev Moves `amount` of tokens from `sender` to `recipient`. 354 | * 355 | * This internal function is equivalent to {transfer}, and can be used to 356 | * e.g. implement automatic token fees, slashing mechanisms, etc. 357 | * 358 | * Emits a {Transfer} event. 359 | * 360 | * Requirements: 361 | * 362 | * - `sender` cannot be the zero address. 363 | * - `recipient` cannot be the zero address. 364 | * - `sender` must have a balance of at least `amount`. 365 | */ 366 | function _transfer( 367 | address sender, 368 | address recipient, 369 | uint256 amount 370 | ) internal virtual { 371 | require(sender != address(0), "ERC20: transfer from the zero address"); 372 | require(recipient != address(0), "ERC20: transfer to the zero address"); 373 | 374 | _beforeTokenTransfer(sender, recipient, amount); 375 | 376 | uint256 senderBalance = _balances[sender]; 377 | require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); 378 | unchecked { 379 | _balances[sender] = senderBalance - amount; 380 | } 381 | _balances[recipient] += amount; 382 | 383 | emit Transfer(sender, recipient, amount); 384 | 385 | _afterTokenTransfer(sender, recipient, amount); 386 | } 387 | 388 | /** @dev Creates `amount` tokens and assigns them to `account`, increasing 389 | * the total supply. 390 | * 391 | * Emits a {Transfer} event with `from` set to the zero address. 392 | * 393 | * Requirements: 394 | * 395 | * - `account` cannot be the zero address. 396 | */ 397 | function _mint(address account, uint256 amount) internal virtual { 398 | require(account != address(0), "ERC20: mint to the zero address"); 399 | 400 | _beforeTokenTransfer(address(0), account, amount); 401 | 402 | _totalSupply += amount; 403 | _balances[account] += amount; 404 | emit Transfer(address(0), account, amount); 405 | 406 | _afterTokenTransfer(address(0), account, amount); 407 | } 408 | 409 | /** 410 | * @dev Destroys `amount` tokens from `account`, reducing the 411 | * total supply. 412 | * 413 | * Emits a {Transfer} event with `to` set to the zero address. 414 | * 415 | * Requirements: 416 | * 417 | * - `account` cannot be the zero address. 418 | * - `account` must have at least `amount` tokens. 419 | */ 420 | function _burn(address account, uint256 amount) internal virtual { 421 | require(account != address(0), "ERC20: burn from the zero address"); 422 | 423 | _beforeTokenTransfer(account, address(0), amount); 424 | 425 | uint256 accountBalance = _balances[account]; 426 | require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); 427 | unchecked { 428 | _balances[account] = accountBalance - amount; 429 | } 430 | _totalSupply -= amount; 431 | 432 | emit Transfer(account, address(0), amount); 433 | 434 | _afterTokenTransfer(account, address(0), amount); 435 | } 436 | 437 | /** 438 | * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. 439 | * 440 | * This internal function is equivalent to `approve`, and can be used to 441 | * e.g. set automatic allowances for certain subsystems, etc. 442 | * 443 | * Emits an {Approval} event. 444 | * 445 | * Requirements: 446 | * 447 | * - `owner` cannot be the zero address. 448 | * - `spender` cannot be the zero address. 449 | */ 450 | function _approve( 451 | address owner, 452 | address spender, 453 | uint256 amount 454 | ) internal virtual { 455 | require(owner != address(0), "ERC20: approve from the zero address"); 456 | require(spender != address(0), "ERC20: approve to the zero address"); 457 | 458 | _allowances[owner][spender] = amount; 459 | emit Approval(owner, spender, amount); 460 | } 461 | 462 | /** 463 | * @dev Hook that is called before any transfer of tokens. This includes 464 | * minting and burning. 465 | * 466 | * Calling conditions: 467 | * 468 | * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens 469 | * will be transferred to `to`. 470 | * - when `from` is zero, `amount` tokens will be minted for `to`. 471 | * - when `to` is zero, `amount` of ``from``'s tokens will be burned. 472 | * - `from` and `to` are never both zero. 473 | * 474 | * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. 475 | */ 476 | function _beforeTokenTransfer( 477 | address from, 478 | address to, 479 | uint256 amount 480 | ) internal virtual {} 481 | 482 | /** 483 | * @dev Hook that is called after any transfer of tokens. This includes 484 | * minting and burning. 485 | * 486 | * Calling conditions: 487 | * 488 | * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens 489 | * has been transferred to `to`. 490 | * - when `from` is zero, `amount` tokens have been minted for `to`. 491 | * - when `to` is zero, `amount` of ``from``'s tokens have been burned. 492 | * - `from` and `to` are never both zero. 493 | * 494 | * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. 495 | */ 496 | function _afterTokenTransfer( 497 | address from, 498 | address to, 499 | uint256 amount 500 | ) internal virtual {} 501 | } 502 | 503 | // File: contracts/token/ERC20/behaviours/ERC20Decimals.sol 504 | 505 | 506 | 507 | pragma solidity ^0.8.0; 508 | 509 | 510 | /** 511 | * @title ERC20Decimals 512 | * @dev Implementation of the ERC20Decimals. Extension of {ERC20} that adds decimals storage slot. 513 | */ 514 | abstract contract ERC20Decimals is ERC20 { 515 | uint8 private immutable _decimals; 516 | 517 | /** 518 | * @dev Sets the value of the `decimals`. This value is immutable, it can only be 519 | * set once during construction. 520 | */ 521 | constructor(uint8 decimals_) { 522 | _decimals = decimals_; 523 | } 524 | 525 | function decimals() public view virtual override returns (uint8) { 526 | return _decimals; 527 | } 528 | } 529 | 530 | // File: contracts/service/ServicePayer.sol 531 | 532 | 533 | 534 | pragma solidity ^0.8.0; 535 | 536 | interface IPayable { 537 | function pay(string memory serviceName) external payable; 538 | } 539 | 540 | /** 541 | * @title ServicePayer 542 | * @dev Implementation of the ServicePayer 543 | */ 544 | abstract contract ServicePayer { 545 | constructor(address payable receiver, string memory serviceName) payable { 546 | IPayable(receiver).pay{value: msg.value}(serviceName); 547 | } 548 | } 549 | 550 | // File: contracts/token/ERC20/StandardERC20.sol 551 | 552 | 553 | 554 | pragma solidity ^0.8.0; 555 | 556 | 557 | 558 | /** 559 | * @title StandardERC20 560 | * @dev Implementation of the StandardERC20 561 | */ 562 | contract StandardERC20 is ERC20Decimals, ServicePayer { 563 | constructor( 564 | string memory name_, 565 | string memory symbol_, 566 | uint8 decimals_, 567 | uint256 initialBalance_, 568 | address payable feeReceiver_ 569 | ) payable ERC20(name_, symbol_) ERC20Decimals(decimals_) ServicePayer(feeReceiver_, "StandardERC20") { 570 | require(initialBalance_ > 0, "StandardERC20: supply cannot be zero"); 571 | 572 | _mint(_msgSender(), initialBalance_); 573 | } 574 | 575 | function decimals() public view virtual override returns (uint8) { 576 | return super.decimals(); 577 | } 578 | } 579 | --------------------------------------------------------------------------------