Build and deploy #Ethereum smart contracts using Visual Studio
The Story: Blockchain and Ethereum network
Build and deploy #Ethereum smart contracts using Visual Studio
A visual of a distributed peer-to-peer application
The Story: Blockchain and Ethereum network
I’ve been sleepless since I got more familiar with Blockchain and the Ethereum network and Smart Contracts.
I have been reading and reading and reading and finally I was able to use some of the tools they recommend in the Ethereum website to build and deploy some smart contracts using the official Ethereum client application (Ethereum Wallet).
I was also able to execute the Smart Contract using the Ethereum client. But then I was like, I need to use a better tool to build smart contracts and they are nothing but pieces of code, so I found out that I can do it within Visual Studio as well as the Visual Studio Code.
What did I do? Built smart contracts with Visual Studio
To build Ethereum Smart Contracts with Visual Studio you need the Solidity Extension found in the Visual Studio Marketplace.
Solidity Extension in Visual Studio Marketplace
First Smart Contract Project
After downloading that, you will have the Solidity Project Template right in the Visual Studio, File => New Project: Then select the “Smart Contract Project” template and click OK.
Solidity Smart Contract Project Template in Visual Studio
As you can see in the Solution Explorer, the template comes with 3 sample Smart Contracts (.sol files) which are our Solidity files.
Solidity Project Template — Smart Contract Samples
Here is how the Payout.sol sample looks like:
Boom, you got your first Ethereum smart contract in Visual Studio.
Compile and Deploy
Next thing you want to do, after you built your brilliant idea with smart contracts, you need to Compile it.
So just right click on the .sol file and select Compile.
Compile a Solidity File from Visual Studio
Now it’s time to deploy your smart contract to the Ethereum network.
To do that we need to setup the project with the Blockchain information, so right click on the project and select Properties:
Smart Contract Project Properties
After entering the Blockchain password, the BlockChain Service URL (Or otherwise known as The RPC Url), you can Deploy your Smart Contract to the network.
Just right click on the Smart Contract (.sol file) and select “Deploy Smart Contract”.
Note: For the Smart Contract deployment to work, you need Geth console to be running on your computer. So if you are deploying to testnet network, open a command prompt and type in below command before clicking on Deploy:
geth --testnet
Deploying a Solidity Smart Contract from Visual Studio
And there you have it. Your distributed application’s back-end services is up and running in the network, and people can execute it as they wish.
Any thing else?
Interested in exploring the smart contract you just deployed, the transations on it an all the details?
You can use the etherscan.io website for the testnet Ethereum network using the address of the contract you just deployed.
The following url is the one i just deployed:
Note: The 0x061e4d089f5341786fade6277d2a0e9526551500 is the public key of the smart contract.
And this is what you will see:
Overview of a Smart Contract on Etherscan website on testnet Ethereum network
As you can see everything in the contract is visible to everyone with 100% transparency!
Book Recommendation
Here are some book recommendation if you are interested: