ARB鏈質押挖礦代幣空投dapp系統開發智慧合約定製
ARB的英文全稱是Arbitrum,專案開發I34-合約I633-定製53I9,Arbitrum是Offchain實驗室開發的一套以太坊擴充套件解決方案,也就是熱門的以太坊L2擴容解決方案,二層擴容解決方案採用Optimistic Rollup技術目的是提高鏈上合約的可擴充套件性、快速性和私有性,並且與其開發者友好的設計與EVM全面相容。
高度可擴充套件性:ARB 鏈採用了一種名為 “二層解決方案” 的技術,可以在鏈外實現高效的交易和支付,從而實現高度可擴充套件性,避免了以太坊等區塊鏈平臺的網路擁堵和交易延遲問題。
高速和低成本:ARB 鏈的交易速度非常快,且交易成本非常低。這使得 ARB 代幣可以被廣泛應用於各種場景,包括支付、轉賬、投資等。
支援 ERC-20 和 ERC-721 標準:ARB 代幣是基於以太坊的 ERC-20 標準發行的,同時也支援 ERC-721 標準,這使得 ARB 代幣可以方便地與其他以太坊代幣進行交易和互操作。
// SPDX-License-Identifier: MIT
pragma solidity ^
0.8
.
0
;
import
"./IERC20.sol"
;
import
"./IERC20Metadata.sol"
;
contract ERC20 is IERC20, IERC20Metadata {
// 地址餘額
mapping(address => uint256)
private
_balances;
// 授權地址餘額
mapping(address => mapping(address => uint256))
private
_allowances;
uint256
private
_totalSupply;
string
private
_name;
string
private
_symbol;
// 設定代幣名稱符號,並初始化鑄造了10000000000代幣在釋出者帳號下。
constructor() {
_name =
"HarryToken"
;
_symbol =
"HYT"
;
_mint(msg.sender,
10000000000
);
}
function name()
public
view virtual override returns (string memory) {
return
_name;
}
function symbol()
public
view virtual override returns (string memory) {
return
_symbol;
}
/// 小數點位數一般為 18
function decimals()
public
view virtual override returns (uint8) {
return
18
;
}
// 返回當前流通代幣的總量
function totalSupply()
public
view virtual override returns (uint256) {
return
_totalSupply;
}
// 查詢指定帳號地址餘額
function balanceOf(address account)
public
view virtual override returns (uint256) {
return
_balances[account];
}
// 轉帳功能
function transfer(address to, uint256 amount)
public
virtual override returns (bool) {
address owner = msg.sender;
_transfer(owner, to, amount);
return
true
;
}
// 獲取被授權者可使用授權帳號的可使用餘額
function allowance(address owner, address spender)
public
view virtual override returns (uint256) {
return
_allowances[owner][spender];
}
// 授權指定帳事情可使用自己一定額度的帳戶餘額。
// 授權spender, 可將自己餘額。使用可使用的餘額的總量為amount
function approve(address spender, uint256 amount)
public
virtual override returns (bool) {
address owner = msg.sender;
_approve(owner, spender, amount);
return
true
;
}
//approve函式中的spender呼叫,將授權人 from 帳戶中的代幣轉入to 帳戶中
function transferFrom(
address from,
address to,
uint256 amount
)
public
virtual override returns (bool) {
address spender = msg.sender;
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return
true
;
}
function increaseAllowance(address spender, uint256 addedValue)
public
virtual returns (bool) {
address owner = msg.sender;
_approve(owner, spender, _allowances[owner][spender] + addedValue);
return
true
;
}
function decreaseAllowance(address spender, uint256 substractedValue)
public
virtual returns (bool) {
address owner = msg.sender;
uint256 currentAllowance = _allowances[owner][spender];
require(currentAllowance >= substractedValue,
"ERC20: decreased allowance below zero"
);
unchecked {
_approve(owner, spender, currentAllowance - substractedValue);
}
return
true
;
}
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(
0
),
"ERC20: transfer from the zero address"
);
require(to != address(
0
),
"ERC20: transfer to the zero address"
);
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount,
"ERC20: transfer amount exceeds balance"
);
unchecked {
_balances[from] = fromBalance - amount;
}
_balances[to] += amount;
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(
0
),
"ERC20: mint to the zero address"
);
_beforeTokenTransfer(address(
0
), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(
0
), account, amount);
_afterTokenTransfer(address(
0
), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(
0
),
"ERC20: burn from the zero address"
);
_beforeTokenTransfer(account, address(
0
), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount,
"ERC20: burn amount exceeds balance"
);
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(
0
), amount);
_afterTokenTransfer(account, address(
0
), amount);
}
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(
0
),
"ERC20: approve from the zero address"
);
require(spender != address(
0
),
"ERC20: approve to the zero address"
);
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if
(currentAllowance != type(uint256).max) {
require(currentAllowance >= amount,
"ERC20: insufficient allowance"
);
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70011332/viewspace-2948119/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- DAPP公鏈代幣質押挖礦系統開發(智慧合約)APP
- DAPP公鏈代幣智慧合約質押挖礦系統開發APP
- ARB鏈代幣空投小遊戲專案dapp系統開發智慧合約定製遊戲APP
- OP鏈DAPP合約代幣質押挖礦系統開發APP
- ARB鏈上代幣合約質押挖礦系統開發丨DAPP技術框架APP框架
- DAPP代幣智慧合約質押挖礦系統開發方案搭建APP
- defi質押挖礦代幣分紅dapp系統開發案例智慧合約模式定製APP模式
- ARB鏈上(代幣合約)質押挖礦系統技術開發(詳情分析)
- ARB鏈上代幣Dapp合約質押挖礦系統開發(python技術框架)APPPython框架
- 智慧合約ARB鏈上質押挖礦系統DAPP開發解析/Solidity編寫APPSolid
- 代幣智慧合約流動性質押挖礦開發穩定版丨代幣智慧合約流動性質押挖礦系統開發方案
- DAPP/Defi代幣智慧合約質押挖礦系統技術開發原理APP
- OP 鏈丨 ARB 鏈代幣合約質押挖礦系統開發案例丨演示丨原始碼原始碼
- DApp智慧合約鏈上盲盒遊戲代幣質押專案挖礦系統開發APP遊戲
- ARB鏈上智慧合約質押挖礦系統開發詳情丨DAPP技術框架APP框架
- DAPP區塊鏈公鏈代幣智慧合約質押挖礦系統開發(Solidity編寫)APP區塊鏈Solid
- 智慧合約LP質押挖礦系統開發DAPPAPP
- 代幣智慧合約質押流動性挖礦分紅開發丨代幣智慧合約質押流動性挖礦分紅系統開發
- ARB鏈上智慧合約質押挖礦系統模型開發技術詳情模型
- ARB鏈OP鏈/defi/Lp/ido/dao代幣DAPP質押專案挖礦系統開發APP
- DAPP智慧合約LP代幣預售質押挖礦系統開發(技術分析)APP
- BSC智慧鏈代幣質押挖礦系統開發方案
- 區塊鏈智慧合約DApp開發系統公鏈質押挖礦系統開發區塊鏈APP
- DAPP馬蹄鏈智慧合約質押挖礦開發丨DAPP馬蹄鏈智慧合約質押挖礦系統開發技術分析及原始碼APP原始碼
- DApp智慧合約鏈上盲盒代幣挖礦系統開發APP
- DAPP/Defi代幣智慧合約開發原理丨LP質押挖礦系統開發詳情APP
- DAPP智慧合約NFT鏈上質押挖礦系統開發搭建方案APP
- DAPP 智慧合約NFT鏈上質押挖礦系統開發詳情APP
- 單雙幣質押流動性挖礦dapp系統開發智慧合約模式定製邏輯APP模式
- Defi代幣預售合約LP質押挖礦系統開發(智慧合約元件分析)元件
- DAPP智慧合約鏈上質押挖礦模式系統開發丨公鏈挖礦系統開發原始碼搭建APP模式原始碼
- DAPP代幣質押挖礦LP系統開發方案APP
- 雲算力質押挖礦dapp系統開發模式詳情(智慧合約定製)APP模式
- 代幣合約流動性質押挖礦開發原始碼版丨代幣合約流動性質押挖礦系統開發(成熟方案)原始碼
- DAPP智慧合約LP質押挖礦系統開發案例搭建APP
- defi質押挖礦智慧合約dapp系統開發詳解APP
- DAPP代幣智慧合約質押挖礦系統技術開發丨IDO丨DAPP丨LPAPP
- 智慧合約馬蹄鏈質押挖礦開發穩定版丨DAPP智慧合約系統開發詳細模型APP模型