- Write a smart contract with semantics defined below, deploy it to Ethereum Ropsten testnet. Please share
contract address and include verified code on Etherscan
contract SimpleToken {
// Create a new token, with default price of 0.01 ETH
// Token ids can start with zero and auto increment
// Current owner is 0x0
// Returns token id
function mint() public returns (uint256);
// Getter & Setter functions for price
function getTokenPrice(uint256 _tokenId) public view returns (uint256);
function setTokenPrice(uint256 _tokenId, uint256 _price) public;
function exists(uint256 _tokenId) public view returns (bool);
// Purchase token at the current price
function purchase(uint256 _tokenId) public payable;
}
- Identify the bugs in the following smart contract.
contract Bank {
// We want an owner that is allowed to selfdestruct.
address owner;
mapping (address => uint) balances;
// Constructor
function Bank(){
owner = msg.sender;
}
// This will take the value of the transaction and add to the senders account.
function deposit() public {
balances[msg.sender] += msg.value;
}
// Attempt to withdraw the given 'amount' of Ether from the account.
function withdraw(uint amount) public {
msg.sender.send(amount);
balances[msg.sender] -= amount;
}
function remove() public {
selfdestruct(owner);
}
}