Posts

Showing posts with the label #TestEther

Send Ether using Javascript and Html

In this post i will be using an html file and javascript to send Ether from one account to another account. the Ideal scenario is "Donations". From one account to another account(Author/Organization). In this process i will make use of Metamask and Web3 and Ropsten Test Net. An Event listener waits for the load of the website and checks if its Web3 Compatible, before proceeding. For the Chrome browser to be Web3 Compatible, it needs to have Metamask installed. Note: You cant run this on your computer as an Html File  Due to browser security restrictions . you will need a web server such as Apache or IIS . <html> <head> <title>Smart Contract Ethereum Aresh</title> </head> <body> <fieldset> <label> Ether: <input type="text" id="amount"></input> </label> <button onclick="sendmoney()">Donate to Aresh</button> <div id="response"...

"Donation Contract" Example

Image
So in this Post i will be writing a Donation Contract. The idea is, The Creator Creates the contract. another person wants to Donate a certain amount of Ether to the Creator. Warning: Tests done with Remix, i can be the creator and send ether to myself without deduction of my own ether. (Im not sure why it allows this.) ideally if i dont have enough ether, it has to revert back, but it doesnt.  (Please help me by commenting Below) pragma solidity ^0.4.0; contract DonationAresh { address creator; //this is Aresh function DonationAresh() public{ creator = msg.sender; } //fall back function that gets an amount of ether and sends to Creator function () payable public{ safeMoney(msg.value); } //send the amount to the creator function safeMoney(uint amountRaised) private{ creator.send(amountRaised); } } So from the Remix IDE there are 5 Accounts. im using the first account as the Creator of the Contr...

Creating Decentralized Apps Part 1

Image
In order to create decentralized Apps such as Web applications, Websites, Mobile Apps. we need a way to interact with the blockchain. Solidity Language is merely for creating a programmable interface that runs on the blockchain So in order for us to interact with the Ethereum network (also called a node) we need to use a Client implementation.  There are many client implementations written in languages such as C++,Go,Python, Java,Haskell etc. Once you have a node using one of the clients, you can sync with the blockchain, create wallets and send and receive real ether. So there are 2 well known client implementations. 1. Test RPC - Node.js based Ethereum client for testing and development 2. Geth - Command line interface written in GO language for running a full Ethereum node Source: https://karl.tech/intro-guide-to-ethereum-testnets/ TestRPC is a lightweight Ethereum nodes used for small scale local testnets. Geth is heavyweight Ethereum nodes used for...

Testing using MetaMask Part 2 "Executing the Contract"

Image
Before writing any javascript code we first need to deploy the contract after deploying we will need 2 things 1. The Contract address 2. The Contract ABI In the next post i will be showing how to use the "web3 Deploy" to get the Contract Address. On the Remix - Solidity IDE. Make sure you are on the "Compile" Tab. Click on the "Details" Button for a popup. scroll down to see the "Interface ABI". (Not needed if you are using Remix IDE) Deploy the contract using the "Web3 Deploy" to get the Contract Address  (Not needed if you are using Remix IDE) Make sure you have Remix IDE open with MetaMask. You will notice the Account Number and number of Ether match. Make sure you have selected "Injected Web3"  Click the "Create" to see a popup Window Requesting for the Transaction. Click "Submit" to Accept the transaction. You will need to wait a minimum of 15 Seconds. In my case i waited ...

Testing using MetaMask Part 1 "Getting Ether"

Image
Download MetaMask On Chrome Browser Accept The "Privacy Notice" Accept The "Terms of Use" Give it a "Password" you wont forget Copy the "Vault" Created to an external text file and save it Select the "Ropsten Test Network" You currently have Zero Ether. Click "Buy" Click the "Ropsten Test Faucet" to open the website Click the "Request 1 Ether from Faucet" and wait for a few seconds Verify from your MetaMask that you have the 1 Ether. Whenever you run out of test ether, you can always request again using the same process