├── README.md ├── contracts └── BitSongToken.sol └── img └── bitsong_logo.png /README.md: -------------------------------------------------------------------------------- 1 | # BitSong smart contract 2 | ![bitsong-logo](img/bitsong_logo.png) 3 | 4 | [BitSong](https://bitsong.io/) - The first decentralized music streaming platform, based on Etherem and IPFS. 5 | 6 | ## Token Standards 7 | Opus token is compliant to the [ERC20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md) standards. 8 | 9 | ## The first decentralized music streaming platform 10 | **BitSong** is a new *music platform*, which will be built using the **Ethereum** blockchain and the **IPFS** distribuited filesystem. 11 | 12 | **BitSong** is a project dedicated to **musicians** and **listeners**, to solve one of the major problems related to the world of music. Problems that a musician who wants to emerge knows very well. 13 | 14 | From today **you will be producing your song**, the advertiser will upload his advertisement and the user will listen to the songs **from any device**. For each advertisement listened, the artist and the listener will get up to 90% of the profits invested by the advertiser. You can also receive donations from your fans for your next album. 15 | 16 | ## Project Vision 17 | Our vision is to create a new brand linked to music streaming, but unlike other platforms, **BitSong will earn both, the artist, the user** the user who listens to the song and finally will also make save money **the advertiser**. 18 | 19 | Our goal is to be present on any TV equipped with **Chromecast or SmartTV**, on any **Smartphone** through **App**, on any personal computer through a **web interface** or software and finally on any car that has a **Smart Radio**. -------------------------------------------------------------------------------- /contracts/BitSongToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.18; 2 | 3 | /** 4 | * @title SafeMath 5 | * @dev Math operations with safety checks that throw on error 6 | */ 7 | library SafeMath { 8 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 9 | if (a == 0) { 10 | return 0; 11 | } 12 | uint256 c = a * b; 13 | assert(c / a == b); 14 | return c; 15 | } 16 | 17 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 18 | // assert(b > 0); // Solidity automatically throws when dividing by 0 19 | uint256 c = a / b; 20 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 21 | return c; 22 | } 23 | 24 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 25 | assert(b <= a); 26 | return a - b; 27 | } 28 | 29 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 30 | uint256 c = a + b; 31 | assert(c >= a); 32 | return c; 33 | } 34 | } 35 | 36 | /** 37 | * @title ERC20Basic 38 | * @dev Simpler version of ERC20 interface 39 | * @dev see https://github.com/ethereum/EIPs/issues/179 40 | */ 41 | contract ERC20Basic { 42 | uint256 public totalSupply; 43 | function balanceOf(address who) public view returns (uint256); 44 | function transfer(address to, uint256 value) public returns (bool); 45 | event Transfer(address indexed from, address indexed to, uint256 value); 46 | } 47 | 48 | /** 49 | * @title ERC20 interface 50 | * @dev see https://github.com/ethereum/EIPs/issues/20 51 | */ 52 | contract ERC20 is ERC20Basic { 53 | function allowance(address owner, address spender) public view returns (uint256); 54 | function transferFrom(address from, address to, uint256 value) public returns (bool); 55 | function approve(address spender, uint256 value) public returns (bool); 56 | event Approval(address indexed owner, address indexed spender, uint256 value); 57 | } 58 | 59 | /** 60 | * @title Basic token 61 | * @dev Basic version of StandardToken, with no allowances. 62 | */ 63 | contract BasicToken is ERC20Basic { 64 | using SafeMath for uint256; 65 | 66 | mapping(address => uint256) balances; 67 | 68 | /** 69 | * @dev transfer token for a specified address 70 | * @param _to The address to transfer to. 71 | * @param _value The amount to be transferred. 72 | */ 73 | function transfer(address _to, uint256 _value) public returns (bool) { 74 | require(_to != address(0)); 75 | require(_value <= balances[msg.sender]); 76 | 77 | // SafeMath.sub will throw if there is not enough balance. 78 | balances[msg.sender] = balances[msg.sender].sub(_value); 79 | balances[_to] = balances[_to].add(_value); 80 | Transfer(msg.sender, _to, _value); 81 | return true; 82 | } 83 | 84 | /** 85 | * @dev Gets the balance of the specified address. 86 | * @param _owner The address to query the the balance of. 87 | * @return An uint256 representing the amount owned by the passed address. 88 | */ 89 | function balanceOf(address _owner) public view returns (uint256 balance) { 90 | return balances[_owner]; 91 | } 92 | 93 | } 94 | 95 | 96 | /** 97 | * @title Standard ERC20 token 98 | * 99 | * @dev Implementation of the basic standard token. 100 | * @dev https://github.com/ethereum/EIPs/issues/20 101 | * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol 102 | */ 103 | contract StandardToken is ERC20, BasicToken { 104 | 105 | mapping (address => mapping (address => uint256)) internal allowed; 106 | 107 | 108 | /** 109 | * @dev Transfer tokens from one address to another 110 | * @param _from address The address which you want to send tokens from 111 | * @param _to address The address which you want to transfer to 112 | * @param _value uint256 the amount of tokens to be transferred 113 | */ 114 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { 115 | require(_to != address(0)); 116 | require(_value <= balances[_from]); 117 | require(_value <= allowed[_from][msg.sender]); 118 | 119 | balances[_from] = balances[_from].sub(_value); 120 | balances[_to] = balances[_to].add(_value); 121 | allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); 122 | Transfer(_from, _to, _value); 123 | return true; 124 | } 125 | 126 | /** 127 | * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. 128 | * 129 | * Beware that changing an allowance with this method brings the risk that someone may use both the old 130 | * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this 131 | * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: 132 | * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 133 | * @param _spender The address which will spend the funds. 134 | * @param _value The amount of tokens to be spent. 135 | */ 136 | function approve(address _spender, uint256 _value) public returns (bool) { 137 | allowed[msg.sender][_spender] = _value; 138 | Approval(msg.sender, _spender, _value); 139 | return true; 140 | } 141 | 142 | /** 143 | * @dev Function to check the amount of tokens that an owner allowed to a spender. 144 | * @param _owner address The address which owns the funds. 145 | * @param _spender address The address which will spend the funds. 146 | * @return A uint256 specifying the amount of tokens still available for the spender. 147 | */ 148 | function allowance(address _owner, address _spender) public view returns (uint256) { 149 | return allowed[_owner][_spender]; 150 | } 151 | 152 | /** 153 | * @dev Increase the amount of tokens that an owner allowed to a spender. 154 | * 155 | * approve should be called when allowed[_spender] == 0. To increment 156 | * allowed value is better to use this function to avoid 2 calls (and wait until 157 | * the first transaction is mined) 158 | * From MonolithDAO Token.sol 159 | * @param _spender The address which will spend the funds. 160 | * @param _addedValue The amount of tokens to increase the allowance by. 161 | */ 162 | function increaseApproval(address _spender, uint _addedValue) public returns (bool) { 163 | allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); 164 | Approval(msg.sender, _spender, allowed[msg.sender][_spender]); 165 | return true; 166 | } 167 | 168 | /** 169 | * @dev Decrease the amount of tokens that an owner allowed to a spender. 170 | * 171 | * approve should be called when allowed[_spender] == 0. To decrement 172 | * allowed value is better to use this function to avoid 2 calls (and wait until 173 | * the first transaction is mined) 174 | * From MonolithDAO Token.sol 175 | * @param _spender The address which will spend the funds. 176 | * @param _subtractedValue The amount of tokens to decrease the allowance by. 177 | */ 178 | function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { 179 | uint oldValue = allowed[msg.sender][_spender]; 180 | if (_subtractedValue > oldValue) { 181 | allowed[msg.sender][_spender] = 0; 182 | } else { 183 | allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); 184 | } 185 | Approval(msg.sender, _spender, allowed[msg.sender][_spender]); 186 | return true; 187 | } 188 | 189 | } 190 | 191 | contract BitsongToken is StandardToken { 192 | 193 | string public constant name = "BitSong"; 194 | string public constant symbol = "BTSG"; 195 | uint8 public constant decimals = 18; 196 | 197 | uint256 public constant INITIAL_SUPPLY = 1000000000 * (10 ** uint256(decimals)); 198 | 199 | /** 200 | * @dev Constructor that gives msg.sender all of existing tokens. 201 | */ 202 | function BitsongToken() public { 203 | totalSupply = INITIAL_SUPPLY; 204 | balances[msg.sender] = INITIAL_SUPPLY; 205 | } 206 | 207 | } -------------------------------------------------------------------------------- /img/bitsong_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitsongofficial/smart-contract/3c11488d2f90e71236369da035d6809a78726822/img/bitsong_logo.png --------------------------------------------------------------------------------