Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Visual Studio to develop ethernet intelligent contract

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Most people don't understand the knowledge points of this article "How to develop Ethereum smart contract with Visual Studio", so Xiaobian summarizes the following contents for everyone. The contents are detailed, the steps are clear, and they have certain reference value. I hope everyone can gain something after reading this article. Let's take a look at this article "How to develop Ethereum smart contract with Visual Studio".

blockchain and Ethereum

Since I became familiar with blockchain, Ethereum and smart contracts, I have been losing sleep.

I kept reading, reading and reading, and finally I was able to use tools that suggested building and deploying some smart contracts using the Ethereum Wallet, the official client application of the Ethereum website.

I was also able to execute smart contracts using Ethereum clients. But I thought, I need to use a better tool to build smart contracts, they are just some code, so I found that I can do it in Visual Studio like Visual Studio Code.

What do I need to do to build smart contracts with Visual Studio?

To build an Ethereum smart contract using Visual Studio, you need to find the solidity extension in the Visual Studio Marketplace.

The first smart contract project

After downloading the component, you will have a solidity development template in Visual Studio. The access path is File => New Project, and then select Smart Contract Project template.

You can see in Solution Explorer that this template has three smart contract files with the extension.sol, which is our solidity file.

Where the Payout.sol example looks like this:

contract Payout { address Victor; address Jim; address Kieren; mapping (address => uint) ownershipDistribution; function Setup() { Victor = 0xaabb; Jim = 0xccdd; Kieren = 0xeeff; ownershipDistribution[Victor] = 35; ownershipDistribution[Jim] = 35; ownershipDistribution[Kieren] = 30; } function Dividend() { uint bal= this.balance; Victor.send(bal * ownershipDistribution[Victor] / 100); Jim.send(bal * ownershipDistribution[Jim] / 100); Kieren.send(bal * ownershipDistribution[Kieren] / 100); }}

And so you get your first Ethereum smart contract in Visual Studio.

Compile and publish

Here's how you want to build a smart contract and compile it.

Right-click the.sol file and select Compile:

Now it's time to deploy your smart contract to Ethereum.

To do this, we need to set up the project with blockchain information, so right-click on the project and select Properties:

After entering the blockchain password, blockchain service URL (or RPC URL), you can deploy smart contracts into the network.

Just right-click on the smart contract (.SOL file) and select Deploy Smart Contract.

Note: In order for smart contract deployment to work, the Geth console needs to be running on your computer. So, if you are deploying to testnet (test chain), open a command prompt and type the following command before clicking Deploy:

geth --testnet

That way you know. The backend service for your decentralized application is up and running in the network, and people can execute it as they wish.

other

Interested in querying the smart contract you just deployed to see its transaction details?

You can use the address of the contract you just deployed to go to testnet on Ethereum using etherscan.io.

The following URL is the URL I just deployed:

Note: 0x061 e4d089f5341786 fade6277 d2a0e9526551500 is the public key of the smart contract.

You will see:

As you can see, everything in the contract is 100% transparent to everyone!

The above is the content of this article on "How to develop Ethereum smart contracts with Visual Studio". I believe everyone has a certain understanding. I hope the content shared by Xiaobian will help everyone. If you want to know more relevant knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report