lockchain is a new application model for computer technology such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithms.
Essentially, a smart contract is a program that automates the processing of traditional contracts through computer instructions. The smart contract program is not just a computer program that can be automatically executed. It is itself a system participant, responding to the received information, receiving and storing value, and also sending information and value outward.
The source code for DApp smart contract development is an important component of blockchain technology and the core code for implementing DApp applications. The following will introduce several common smart contract development source codes:
Solidity
Solidity is the most popular smart contract programming language at present, and is widely used on blockchain platforms such as Ethereum. It is built based on languages such as JavaScript and C++, and supports OOP (Object Oriented Programming) ideas and multiple data types. In addition, Solidity provides a series of security mechanisms, such as permission control, exception handling, and so on.
Vyper
Vyper is an emerging smart contract programming language, focusing on simplifying the development process of Ethereum smart contracts. Unlike Solidity, Vyper adopts a more concise syntax and fewer features, aiming to improve the readability and security of smart contracts.
Rust
Rust is a system level programming language, with its powerful memory management capabilities and concurrency making it an ideal smart contract programming language. The syntax of Rust is similar to C++, and it supports both Functional programming and object-oriented programming.
Go
Go is another popular smart contract programming language with high execution efficiency and good scalability. The grammar of Go language is concise and easy to understand, and it is also widely used in blockchain application development.
In short, the source code for developing DApp smart contracts is the core code for implementing DApp applications. The Solidity, Vyper, Rust, and Go mentioned above are common smart contract programming languages. Developers need to choose suitable smart contract development source code based on specific application requirements and technical characteristics, and master corresponding development techniques and tools in order to better implement DApp applications and create commercial value.
部署Uniswap前端
克隆前端代码
安装依赖库
在项目目录运行命令:
$ cd uniswap-interface
$ yarn
安装完成后,可以先测试运行一下,在uniswap-interface目录运行命令
$ yarn start
如果运行成功,将会打开一个浏览器,同时打开Uniswap的前端界面
修改路由地址
在Uniswap的前端中以常量的形式定义了Uniswap的路由地址,我们只需要修改路由地址就可以让前端链接到你的路由合约中 修改文件: 项目目录/uniswap-interface/src/constants/index.ts 第6行
import { AbstractConnector } from '@web3-react/abstract-connector'
import { ChainId, JSBI, Percent, Token, WETH } from '@uniswap/sdk'
import { fortmatic, injected, portis, walletconnect, walletlink } from '../connectors'
export const ROUTER_ADDRESS = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D' //修改成你的路由合约地址
......
保存后运行yarn start即可看到效果
将代码部署到GitHub Pages
创建GitHub项目
创建项目的方法就不在这里讲了,不会的同学可以去搜索一下
将前端代码添加到GitHub项目仓库
首先要删除原先Uniswap项目中的.git目录,在项目目录运行命令:
$ cd uniswap-interface
$ rm -rf .git
然后初始化git,并将Unsiwap前端代码添加到自己的项目仓库中
git init
git remote add origin
安装并部署gh-pages
我们将通过gh-pages模块将前端代码部署到github.io,在前端代码的目录运行:
$ yarn add gh-pages
接下来要编译react和部署gh-pages,在前端代码的目录运行:
$ yarn build
修改前端代码目录中的package.json
$ vim package.json
{
"name": "@uniswap/interface",
"description": "Uniswap Interface",
"homepage":
......
// 添加部署的脚本,还是在package.json中
......
"scripts": {
......
"deploy": "gh-pages -d build" //添加这一行
},
保存退出之后,在前端代码的目录运行:
$ git add .
$ git commit -m "first commit"
$ git push
$ yarn deploy