Commit 64ff5766 authored by hezhengjun's avatar hezhengjun

add deploy for tether usdt

parent e659dd7a
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"github.com/33cn/plugin/plugin/dapp/cross2eth/contracts/contracts4eth/generated" "github.com/33cn/plugin/plugin/dapp/cross2eth/contracts/contracts4eth/generated"
erc20 "github.com/33cn/plugin/plugin/dapp/cross2eth/contracts/erc20/generated" erc20 "github.com/33cn/plugin/plugin/dapp/cross2eth/contracts/erc20/generated"
tetherUSDT "github.com/33cn/plugin/plugin/dapp/cross2eth/contracts/usdt/generated"
"github.com/33cn/plugin/plugin/dapp/cross2eth/ebrelayer/utils" "github.com/33cn/plugin/plugin/dapp/cross2eth/ebrelayer/utils"
"github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
...@@ -103,6 +104,76 @@ func DeployERC20(cmd *cobra.Command, _ []string) { ...@@ -103,6 +104,76 @@ func DeployERC20(cmd *cobra.Command, _ []string) {
} }
} }
func DeployTetherUSDTCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "create_tether_usdt",
Short: "create tether usdt contracts",
Run: DeployTetherUSDT,
}
DeployTetherUSDTFlags(cmd)
return cmd
}
func DeployTetherUSDTFlags(cmd *cobra.Command) {
cmd.Flags().StringP("deployAddr", "d", "", "deploy contract addr")
_ = cmd.MarkFlagRequired("deployAddr")
cmd.Flags().StringP("symbol", "s", "", "erc20 symbol")
_ = cmd.MarkFlagRequired("symbol")
cmd.Flags().StringP("amount", "m", "0", "amount")
_ = cmd.MarkFlagRequired("amount")
}
func DeployTetherUSDT(cmd *cobra.Command, _ []string) {
url, _ := cmd.Flags().GetString("rpc_laddr_ethereum")
deployerAddr, _ := cmd.Flags().GetString("deployAddr")
symbol, _ := cmd.Flags().GetString("symbol")
amount, _ := cmd.Flags().GetString("amount")
bnAmount := big.NewInt(1e6 * 1e6)
bnAmount, _ = bnAmount.SetString(utils.TrimZeroAndDot(amount), 10)
client, err := ethclient.Dial(url)
if err != nil {
fmt.Println("ethclient Dial error", err.Error())
return
}
ctx := context.Background()
startNonce, err := client.PendingNonceAt(ctx, common.HexToAddress(deployerAddr))
if nil != err {
fmt.Println("PendingNonceAt error", err.Error())
return
}
var infos []*DeployInfo
parsed, err := abi.JSON(strings.NewReader(tetherUSDT.TetherTokenABI))
if err != nil {
fmt.Println("abi.JSON(strings.NewReader(tetherUSDT.TetherTokenABI)) error", err.Error())
return
}
bin := common.FromHex(tetherUSDT.TetherTokenBin)
//function TetherToken(uint _initialSupply, string _name, string _symbol, uint _decimals)
packdata, err := parsed.Pack("", bnAmount, symbol, symbol, big.NewInt(6))
if err != nil {
fmt.Println("Pack error", err.Error())
return
}
Erc20Addr := crypto.CreateAddress(common.HexToAddress(deployerAddr), startNonce)
deployInfo := DeployInfo{
PackData: append(bin, packdata...),
ContractorAddr: Erc20Addr,
Name: "Erc20: " + symbol,
Nonce: startNonce,
To: nil,
}
infos = append(infos, &deployInfo)
fileName := "deployTetherUSDT.txt"
err = NewTxWrite(infos, common.HexToAddress(deployerAddr), url, fileName)
if err != nil {
fmt.Println("NewTxWrite error", err.Error())
return
}
}
func CreateAddToken2LockListTxCmd() *cobra.Command { func CreateAddToken2LockListTxCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "create_add_lock_list", Use: "create_add_lock_list",
......
...@@ -34,6 +34,7 @@ func DeployOfflineContractsCmd() *cobra.Command { ...@@ -34,6 +34,7 @@ func DeployOfflineContractsCmd() *cobra.Command {
CreateCmd(), //构造交易 CreateCmd(), //构造交易
CreateWithFileCmd(), CreateWithFileCmd(),
DeployERC20Cmd(), DeployERC20Cmd(),
DeployTetherUSDTCmd(),
CreateCfgAccountTxCmd(), // set_offline_addr 设置离线多签地址 CreateCfgAccountTxCmd(), // set_offline_addr 设置离线多签地址
SetupCmd(), SetupCmd(),
ConfigLockedTokenOfflineSaveCmd(), ConfigLockedTokenOfflineSaveCmd(),
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
SRC_BEP := bep20 SRC_BEP := bep20
SRC_ERC20 := erc20 SRC_ERC20 := erc20
SRC_USDT := usdt
SRC_CONTRACT0 := contracts4chain33 SRC_CONTRACT0 := contracts4chain33
SRC_CONTRACT1 := contracts4eth SRC_CONTRACT1 := contracts4eth
SRC_MULTISIGN := gnosis/safe-contracts/contracts SRC_MULTISIGN := gnosis/safe-contracts/contracts
...@@ -12,6 +13,7 @@ GO_OUT1 := ${SRC_CONTRACT1}/generated ...@@ -12,6 +13,7 @@ GO_OUT1 := ${SRC_CONTRACT1}/generated
GO_OUT_MULTISIGN := gnosis/generated GO_OUT_MULTISIGN := gnosis/generated
GO_OUT_BEP20 := bep20/generated GO_OUT_BEP20 := bep20/generated
GO_OUT_ERC20 := erc20/generated GO_OUT_ERC20 := erc20/generated
GO_OUT_USDT := usdt/generated
PACKAGE := generated PACKAGE := generated
proj := "build" proj := "build"
...@@ -35,6 +37,9 @@ bep20Bin: ...@@ -35,6 +37,9 @@ bep20Bin:
erc20Bin: erc20Bin:
@abigen --sol $(SRC_ERC20)/ERC20.sol --pkg $(PACKAGE) --out $(GO_OUT_ERC20)/erc20.go @abigen --sol $(SRC_ERC20)/ERC20.sol --pkg $(PACKAGE) --out $(GO_OUT_ERC20)/erc20.go
usdtBin:
@abigen --alias _totalSupply=_totalSupply4usdt --sol $(SRC_USDT)/USDT.sol --pkg $(PACKAGE) --out $(GO_OUT_USDT)/usdt.go
clean: clean:
@rm -fr $(GO_OUT)/* @rm -fr $(GO_OUT)/*
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment