Basic Attention Token
ERC20
This contract is an ERC20 token.
Name
Basic Attention Token
Symbol
BAT
Decimals
18
Total Supply
1,500,000,000 BAT
About
link
description
Led by Brendan Eich (creator of JavaScript and co-founder of Mozilla), Basic Attention Token (BAT) project is an open-source, decentralized ad exchange platform built on the Ethereum platform. The project seeks to address fraud and opaqueness in digital advertising.
The token aims to correctly price user attention within the platform. Advertisers pay BAT to website publishers for the attention of users. The BAT ecosystem includes Brave, an open-source, privacy-centered browser designed to block trackers and malware. It leverages blockchain technology to anonymously and track user attention securely and rewards publishers accordingly.
Stats
Public Functions
8
Event Types
4
Code Size
6,902 bytes
Events (4) keyboard_arrow_up
Functions
balanceOf keyboard_arrow_up
transfer keyboard_arrow_up
Source Code
function transfer(address _to, uint256 _value) returns (bool success) {
if (balances[msg.sender] >= _value && _value > 0) {
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
} else {
return false;
}
}
transferFrom keyboard_arrow_up
Source Code
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] += _value;
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
} else {
return false;
}
}
approve keyboard_arrow_up
Source Code
function approve(address _spender, uint256 _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
allowance keyboard_arrow_up
createTokens keyboard_arrow_up
Parameters help
This function has no parameters.
Requirements help
Source Code
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
}
finalize keyboard_arrow_up
Parameters help
This function has no parameters.
Requirements help
One or more of the following:
-
totalSupply
must be equal to
tokenCreationCap
- OR
fundingEndBlock
must be less than
block.number
Source Code
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 && totalSupply != tokenCreationCap) throw;
// move to operational
isFinalized = true;
if(!ethFundDeposit.send(this.balance)) throw; // send the eth to Brave International
}
refund keyboard_arrow_up
Parameters help
This function has no parameters.
Requirements help
Source Code
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
}