0%
    Verified
  • Verified, Token
  • Basic Attention Token
  • Fungible Token
  • ERC-20

The following smart contract is for the Basic Attention Token (BAT) which is an ERC20 token. It allows users to create tokens by sending Ether to the contract during a specified funding period. The token exchange rate is fixed at 6400 BAT per Ether. The contract has a token creation cap of 1.5 billion BAT and a minimum creation amount of 675 million BAT. The contract can be finalized by the owner after the funding period ends, and any remaining Ether is sent to the owner. If the minimum creation amount is not met, users can request a refund of their Ether.

0x0d8775f648430679a709e98d2b0cb6250d2887ef
Copied
Copied
BAToken Source Code
pragma solidity ^0.4.10; /* taking ideas from FirstBlood token */ contract SafeMath { /* function assert(bool assertion) internal { */ /* if (!assertion) { */ /* throw; */ /* } */ /* } // assert no longer needed once solidity is on 0.4.10 */ function safeAdd(uint256 x, uint256 y) internal returns(uint256) { uint256 z = x + y; assert((z >= x) &amp;&amp; (z >= y)); return z; } function safeSubtract(uint256 x, uint256 y) internal returns(uint256) { assert(x >= y); uint256 z = x - y; return z; } function safeMult(uint256 x, uint256 y) internal returns(uint256) { uint256 z = x * y; assert((x == 0)||(z/x == y)); return z; } } contract Token { uint256 public totalSupply; function balanceOf(address _owner) constant returns (uint256 balance); function transfer(address _to, uint256 _value) returns (bool success); function transferFrom(address _from, address _to, uint256 _value) returns (bool success); function approve(address _spender, uint256 _value) returns (bool success); function allowance(address _owner, address _spender) constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } /* ERC 20 token */ contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value &amp;&amp; _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balances[_from] >= _value &amp;&amp; allowed[_from][msg.sender] >= _value &amp;&amp; _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; } contract BAToken is StandardToken, SafeMath { // metadata string public constant name = "Basic Attention Token"; string public constant symbol = "BAT"; uint256 public constant decimals = 18; string public version = "1.0"; // contracts address public ethFundDeposit; // deposit address for ETH for Brave International address public batFundDeposit; // deposit address for Brave International use and BAT User Fund // crowdsale parameters bool public isFinalized; // switched to true in operational state uint256 public fundingStartBlock; uint256 public fundingEndBlock; uint256 public constant batFund = 500 * (10**6) * 10**decimals; // 500m BAT reserved for Brave Intl use uint256 public constant tokenExchangeRate = 6400; // 6400 BAT tokens per 1 ETH uint256 public constant tokenCreationCap = 1500 * (10**6) * 10**decimals; uint256 public constant tokenCreationMin = 675 * (10**6) * 10**decimals; // events event LogRefund(address indexed _to, uint256 _value); event CreateBAT(address indexed _to, uint256 _value); // constructor function BAToken( address _ethFundDeposit, address _batFundDeposit, uint256 _fundingStartBlock, uint256 _fundingEndBlock) { isFinalized = false; //controls pre through crowdsale state ethFundDeposit = _ethFundDeposit; batFundDeposit = _batFundDeposit; fundingStartBlock = _fundingStartBlock; fundingEndBlock = _fundingEndBlock; totalSupply = batFund; balances[batFundDeposit] = batFund; // Deposit Brave Intl share CreateBAT(batFundDeposit, batFund); // logs Brave Intl fund } /// @dev Accepts ether and creates new BAT tokens. function createTokens() payable external { if (isFinalized) throw; if (block.number < fundingStartBlock) throw; if (block.number > fundingEndBlock) throw; if (msg.value == 0) throw; uint256 tokens = safeMult(msg.value, tokenExchangeRate); // check that we're not over totals uint256 checkedSupply = safeAdd(totalSupply, tokens); // return money if something goes wrong if (tokenCreationCap < checkedSupply) throw; // odd fractions won't be found totalSupply = checkedSupply; balances[msg.sender] += tokens; // safeAdd not needed; bad semantics to use here CreateBAT(msg.sender, tokens); // logs token creation } /// @dev Ends the funding period and sends the ETH home function finalize() external { if (isFinalized) throw; if (msg.sender != ethFundDeposit) throw; // locks finalize to the ultimate ETH owner if(totalSupply < tokenCreationMin) throw; // have to sell minimum to move to operational if(block.number <= fundingEndBlock &amp;&amp; totalSupply != tokenCreationCap) throw; // move to operational isFinalized = true; if(!ethFundDeposit.send(this.balance)) throw; // send the eth to Brave International } /// @dev Allows contributors to recover their ether in the case of a failed funding campaign. function refund() external { if(isFinalized) throw; // prevents refund if operational if (block.number <= fundingEndBlock) throw; // prevents refund until sale period is over if(totalSupply >= tokenCreationMin) throw; // no refunds if we sold enough if(msg.sender == batFundDeposit) throw; // Brave Intl not entitled to a refund uint256 batVal = balances[msg.sender]; if (batVal == 0) throw; balances[msg.sender] = 0; totalSupply = safeSubtract(totalSupply, batVal); // extra safe uint256 ethVal = batVal / tokenExchangeRate; // should be safe; previous throws covers edges LogRefund(msg.sender, ethVal); // log it if (!msg.sender.send(ethVal)) throw; // if you're using a contract; make sure it works with .send gas limits } }
BAToken ABI
Copied
[{"constant":true,"inputs":[],"name":"batFundDeposit","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"batFund","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"tokenExchangeRate","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"finalize","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"version","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"refund","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"tokenCreationCap","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"isFinalized","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"fundingEndBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"ethFundDeposit","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"createTokens","outputs":[],"payable":true,"type":"function"},{"constant":true,"inputs":[],"name":"tokenCreationMin","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"fundingStartBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"_ethFundDeposit","type":"address"},{"name":"_batFundDeposit","type":"address"},{"name":"_fundingStartBlock","type":"uint256"},{"name":"_fundingEndBlock","type":"uint256"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"LogRefund","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"CreateBAT","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}]
BAToken Bytecode
Copied
60a0604052600360608190527f312e300000000000000000000000000000000000000000000000000000000000608090815261003c919081610114565b50341561004557fe5b604051608080610e9783398101604090815281516020830151918301516060909301519092905b6005805460048054600160a060020a031916600160a060020a0388811691909117909155600160a860020a031990911685821617808355600685905560078490556b019d971e4fe8401e74000000600081815591831682526001602090815260409283902082905593548251918252915191909216927fb33527d2e0d30b7aece2c5e82927985866c1b75173d671c14f4457bf67aa6910928290030190a25b505050506101b4565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061015557805160ff1916838001178555610182565b82800160010185558215610182579182015b82811115610182578251825591602001919060010190610167565b5b5061018f929150610193565b5090565b6101b191905b8082111561018f5760008155600101610199565b5090565b90565b610cd4806101c36000396000f3006060604052361561010c5763ffffffff60e060020a60003504166301a7a8c0811461010e57806306fdde031461013a578063095ea7b3146101ca57806318160ddd146101fd578063229a49781461021f57806323b872dd14610241578063313ce5671461027a5780634172d0801461029c5780634bb278f3146102be57806354fd4d50146102d0578063590e1ae3146103605780636f7920fd1461037257806370a08231146103945780638d4e4083146103c257806391b43d13146103e657806395d89b4114610408578063a81c3bdf14610498578063a9059cbb146104c4578063b4427263146104f7578063c039daf614610501578063d648a64714610523578063dd62ed3e14610545575bfe5b341561011657fe5b61011e610579565b60408051600160a060020a039092168252519081900360200190f35b341561014257fe5b61014a610588565b604080516020808252835181830152835191928392908301918501908083838215610190575b80518252602083111561019057601f199092019160209182019101610170565b505050905090810190601f1680156101bc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101d257fe5b6101e9600160a060020a03600435166024356105bf565b604080519115158252519081900360200190f35b341561020557fe5b61020d61062a565b60408051918252519081900360200190f35b341561022757fe5b61020d610630565b60408051918252519081900360200190f35b341561024957fe5b6101e9600160a060020a0360043581169060243516604435610640565b604080519115158252519081900360200190f35b341561028257fe5b61020d610736565b60408051918252519081900360200190f35b34156102a457fe5b61020d61073b565b60408051918252519081900360200190f35b34156102c657fe5b6102ce610741565b005b34156102d857fe5b61014a61081a565b604080516020808252835181830152835191928392908301918501908083838215610190575b80518252602083111561019057601f199092019160209182019101610170565b505050905090810190601f1680156101bc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561036857fe5b6102ce6108a8565b005b341561037a57fe5b61020d6109dd565b60408051918252519081900360200190f35b341561039c57fe5b61020d600160a060020a03600435166109ed565b60408051918252519081900360200190f35b34156103ca57fe5b6101e9610a0c565b604080519115158252519081900360200190f35b34156103ee57fe5b61020d610a1c565b60408051918252519081900360200190f35b341561041057fe5b61014a610a22565b604080516020808252835181830152835191928392908301918501908083838215610190575b80518252602083111561019057601f199092019160209182019101610170565b505050905090810190601f1680156101bc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156104a057fe5b61011e610a59565b60408051600160a060020a039092168252519081900360200190f35b34156104cc57fe5b6101e9600160a060020a0360043516602435610a68565b604080519115158252519081900360200190f35b6102ce610b14565b005b341561050957fe5b61020d610bf3565b60408051918252519081900360200190f35b341561052b57fe5b61020d610c03565b60408051918252519081900360200190f35b341561054d57fe5b61020d600160a060020a0360043581169060243516610c09565b60408051918252519081900360200190f35b600554600160a060020a031681565b60408051808201909152601581527f426173696320417474656e74696f6e20546f6b656e0000000000000000000000602082015281565b600160a060020a03338116600081815260026020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60005481565b6b019d971e4fe8401e7400000081565b600160a060020a0383166000908152600160205260408120548290108015906106905750600160a060020a0380851660009081526002602090815260408083203390941683529290522054829010155b801561069c5750600082115b1561072a57600160a060020a03808416600081815260016020908152604080832080548801905588851680845281842080548990039055600283528184203390961684529482529182902080548790039055815186815291519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600161072e565b5060005b5b9392505050565b601281565b61190081565b60055460a060020a900460ff16156107595760006000fd5b60045433600160a060020a039081169116146107755760006000fd5b6000546b022e58cf5246568f830000009010156107925760006000fd5b60075443111580156107b257506000546b04d8c55aefb8c05b5c00000014155b156107bd5760006000fd5b6005805474ff0000000000000000000000000000000000000000191660a060020a179055600454604051600160a060020a039182169130163180156108fc02916000818181858888f1935050505015156108175760006000fd5b5b565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156108a05780601f10610875576101008083540402835291602001916108a0565b820191906000526020600020905b81548152906001019060200180831161088357829003601f168201915b505050505081565b600554600090819060a060020a900460ff16156108c55760006000fd5b60075443116108d45760006000fd5b6000546b022e58cf5246568f8300000090106108f05760006000fd5b60055433600160a060020a039081169116141561090d5760006000fd5b600160a060020a03331660009081526001602052604090205491508115156109355760006000fd5b600160a060020a03331660009081526001602052604081208190555461095b9083610c36565b600055611900825b04905033600160a060020a03167fb6c0eca8138e097d71e2dd31e19a1266487f0553f170b7260ffe68bcbe9ff8a7826040518082815260200191505060405180910390a2604051600160a060020a0333169082156108fc029083906000818181858888f1935050505015156109d85760006000fd5b5b5050565b6b04d8c55aefb8c05b5c00000081565b600160a060020a0381166000908152600160205260409020545b919050565b60055460a060020a900460ff1681565b60075481565b60408051808201909152600381527f4241540000000000000000000000000000000000000000000000000000000000602082015281565b600454600160a060020a031681565b600160a060020a033316600090815260016020526040812054829010801590610a915750600082115b15610b0557600160a060020a03338116600081815260016020908152604080832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a3506001610624565b506000610624565b5b92915050565b600554600090819060a060020a900460ff1615610b315760006000fd5b600654431015610b415760006000fd5b600754431115610b515760006000fd5b341515610b5e5760006000fd5b610b6a34611900610c51565b9150610b7860005483610c80565b90506b04d8c55aefb8c05b5c00000081901015610b955760006000fd5b6000818155600160a060020a033316808252600160209081526040928390208054860190558251858152925191927fb33527d2e0d30b7aece2c5e82927985866c1b75173d671c14f4457bf67aa6910929081900390910190a25b5050565b6b022e58cf5246568f8300000081565b60065481565b600160a060020a038083166000908152600260209081526040808320938516835292905220545b92915050565b60008082841015610c4357fe5b5050808203805b5092915050565b6000828202831580610c6d5750828482811515610c6a57fe5b04145b1515610c7557fe5b8091505b5092915050565b6000828201838110801590610c6d5750828110155b1515610c7557fe5b8091505b50929150505600a165627a7a72305820e7d550d22cfb06e8da1efe14627217183e846b5986b9bac6199503c4780b03d70029000000000000000000000000ac2fa512db158f44f5ee2fa5766ea7c282763cdb00000000000000000000000088e2efac3d2ef957fcd82ec201a506871ad06204000000000000000000000000000000000000000000000000000000000039f67000000000000000000000000000000000000000000000000000000000003c7a58
Smart Contracts contract page background

Checkout more smart contracts

    Ethereum  logo

    SHILAINU

    Verified

    The following smart contract is the SHILAINU token contract, which is an ERC20 token with a total supply of 1 trillion. It includes features such as transaction limits, fees, and automatic liquidity provision. The contract also has a blacklist mode and the ability to set fee and transaction exemptions for specific addresses. The purpose of the contract is to provide a decentralized currency for the Shiba Inu community.

    0x20c3fa331a385b63ee39137e99d0cf2db142fce1
    Copied
    • Verified
    • Fungible Token
    • ERC20
    Ethereum  logo

    LooksRareAirdrop

    Verified

    The following smart contract is a LooksRareAirdrop contract that allows users to claim airdrop rewards in the form of ERC20 tokens. Users must provide a valid merkle proof and meet certain requirements, including having a signed maker order and approval for the collection. The contract is pausable and has a maximum amount that can be claimed. The owner can set the merkle root, update the end timestamp, and withdraw token rewards.

    0xa35dce3e0e6ceb67a30b8d7f4aee721c949b5970
    Copied
    • Verified, Token
    • LooksRare
    • Fungible Token
    • ERC-20
    Ethereum  logo

    WETH9

    Verified

    The following smart contract is a basic implementation of the Wrapped Ether (WETH) token on the Ethereum blockchain. It allows users to deposit Ether into the contract and receive WETH tokens in return, which can be transferred to other users or contracts. The contract also includes functions for withdrawing Ether, checking balances, and approving transfers. The WETH token has a fixed supply of 18 decimal places and is represented by the symbol "WETH".

    0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
    Copied
    • Verified, Token
    • Fungible Token
    • ERC-20
Section background image

Build blockchain magic with Alchemy

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.