Ethereum Token/Coin (Aj007)

Ethereum Coin Aj007

Solidity Smart Contract


pragma solidity 0.4.8;
contract Aj007{

	mapping (address => uint256) public balanceOf;
	// allowing others to execute transactions on your behalf
	mapping (address => mapping (address => uint256)) public allowance;
	
	// balanceOf[address] = 5;
	string public standard = "Aj007 v1.0";
	string public name;
	string public symbol;
	uint8 public decimal; // 1.23 Number of decimal
	uint256 public totalSupply;
	//indexed address passsed will be stored in log memory and not contract data
	event Transfer(address indexed from, address indexed to, uint256 _value);

	function  Aj007 (uint256 initialSupply, string tokenName, string tokenSymbol, uint8 decimalUnits){
		balanceOf[msg.sender] = initialSupply;
		totalSupply = initialSupply;
		decimal = decimalUnits;
		name = tokenName;
		symbol = tokenSymbol;

	} 

	function transfer (address _to,uint256 _value){
		if(balanceOf[msg.sender] < _value) throw;
		//0-255 8 bit
		// 250,10 = 4 Buffer overflow
		if(balanceOf[_to] + _value < balanceOf [_to]) throw;
		// Any number of conditions can be added here
		balanceOf[msg.sender] -= _value;
		balanceOf[_to] += _value;
		// Can be used for debugging values of smart contract and also act as an event for other clients
		// Technically a logging method
		Transfer(msg.sender,_to,_value);
	}

	function approve (address _spender, uint256 _value) returns(bool res){
		allowance[msg.sender][_spender] = _value;
		return true;
	}
	
	function transferFrom (address _from, address _to, uint256 _value) returns(bool res){
		if(balanceOf[_from] < _value) throw;
		if(balanceOf[_to] + _value < balanceOf[_to]) throw; if(_value > allowance[_from][msg.sender]) throw;

		balanceOf[_from] -= _value;
		balanceOf[_to] += _value;

		allowance[_from][msg.sender] -= _value;

		Transfer(_from,_to, _value);
		return true;
	}
	
}

Minimum Viable Token (MVT)

Creation of Smart Contract Token on Ethereum Network.

Minimum Viable Token


pragma solidity 0.4.8;
contract Aj007{

mapping (address => uint256) public balanceOf;
// balanceOf[address] = 5;
string public standard = "Aj007 v1.0";
string public name;
string public symbol;
uint8 public decimal;

function Aj007 (uint256 initialSupply){
balanceOf[msg.sender] = initialSupply;
}

function transfer (address _to,uint256 _value){
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
}

}

Deploy Smart Contract in Ethereum Consortium

This can be done in many ways.

One of the ways is to use the Ethereum Remix IDE

Ethereum Remix IDE: https://remix.ethereum.org/

Remix will auto compile the code if you have selected “Auto Compile” else click on  to compile you code. Now we will deploy this smart contract in Ethereum Consortium Blockchain, which we had created.

Deploy smart contracts on azure ethereum consortium blockchain

To deploy smart contract, we will use Remix only. In remix browser click on “Run” tab, which is located on top right side of screen

From “Environment” drop down select “Web3 Provider”. It will show a pop up like shown below.

Click on OK. Now you need to provide “Web3 Provider Endpoint” for you Ethereum blockchain network. It is the “ethereum-rpc-endpoint”  value which we had saved from Azure portal as part of step1. Paste this value in popup window and click on “OK”.

Now It will show you some values in “Account” dropdown, which was earlier blank. Now we have connected remix IDE with in Ethereum Consortium Blockchain. Lets deploy smart contract. Click on “Create”


Ethereum or Mist Wallet

You can also make use of the Ethereum or mist wallet from your local system and connect to the transactionn node on the remote azure consortium deployment.

Command:

./ethereumwallet --rpc --rpcapi="db,eth,net,web3,personal,web3" ethereum admin side from Consortium deployment

./mist --rpc --rpcapi="db,eth,net,web3,personal,web3" ethereum admin side from Consortium deployment

Eg:./ethereumwallet --rpc --rpcapi="db,eth,net,web3,personal,web3" http://a3uc7l-dns-reg1.eastus.cloudapp.azure.com:8545

The Ethereum/Mist wallet would provide with more convinient UI and access to the remote Transaction node and would facilitate easy deployment of the Smart Contract.

Reference: https://blogs.msdn.microsoft.com/reenusaluja/2018/03/12/deploy-your-first-smart-contract-on-azure-ethereum-consortium-blockchain/

Ethereum Consortium

Proceed with the deployment as stated in the official reference document.

Reference Docs : https://docs.microsoft.com/en-us/azure/blockchain-workbench/ethereum-deployment-guide

#Some usefull commands to access the rpc from remote terminals:

geth --dev --rpc --rpcaddr "0.0.0.0"
geth -rpc --rpcapi="db,eth,net,web3,personal,web3"
geth --dev --rpc --rpcaddr "0.0.0.0" --rpcapi "eth,net,web3,admin,personal" [...]

#You can multiple instance of the Geth on different ports using --port flag and just run all Geth instance with --ipcdisable flag


geth [...] --rpc --rpcport 8546 --rpcaddr "0.0.0.0" --rpcapi "eth,net,web3,admin,personal" [...] --dev

./ethereumwallet --rpc --rpcapi="db,eth,net,web3,personal,web3" http://a3uc7l-dns-reg1.eastus.cloudapp.azure.com:8545

Wallets

Ethereum Wallet: https://github.com/ethereum/mist/releases

Mist: https://github.com/ethereum/mist/releases

MetaMask: https://metamask.io/