Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
1394bb36
Commit
1394bb36
authored
Dec 24, 2021
by
hezhengjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add bep20 deploy tool
parent
0728e1aa
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
8 deletions
+100
-8
Erc20AndBridgeToken.go
.../cross2eth/boss4x/ethereum/offline/Erc20AndBridgeToken.go
+81
-0
offline.go
plugin/dapp/cross2eth/boss4x/ethereum/offline/offline.go
+1
-0
BEP20.sol
plugin/dapp/cross2eth/contracts/bep20/BEP20.sol
+18
-8
bep20.go
plugin/dapp/cross2eth/contracts/bep20/generated/bep20.go
+0
-0
No files found.
plugin/dapp/cross2eth/boss4x/ethereum/offline/Erc20AndBridgeToken.go
View file @
1394bb36
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"math/big"
"math/big"
"strings"
"strings"
bep20
"github.com/33cn/plugin/plugin/dapp/cross2eth/contracts/bep20/generated"
"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"
tetherUSDT
"github.com/33cn/plugin/plugin/dapp/cross2eth/contracts/usdt/generated"
...
@@ -31,6 +32,86 @@ import (
...
@@ -31,6 +32,86 @@ import (
./boss4x ethereum offline send -f deploysigntxs.txt
./boss4x ethereum offline send -f deploysigntxs.txt
*/
*/
func
DeployBEP20Cmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"deploy_bep20"
,
Short
:
"deploy BEP20 contracts"
,
Run
:
DeployBEP20
,
}
DeployBEP20Flags
(
cmd
)
return
cmd
}
func
DeployBEP20Flags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"deployAddr"
,
"a"
,
""
,
"addr to deploy contract "
)
_
=
cmd
.
MarkFlagRequired
(
"deployAddr"
)
cmd
.
Flags
()
.
StringP
(
"owner"
,
"o"
,
""
,
"owner address"
)
_
=
cmd
.
MarkFlagRequired
(
"owner"
)
cmd
.
Flags
()
.
StringP
(
"symbol"
,
"s"
,
""
,
"BEP20 symbol"
)
_
=
cmd
.
MarkFlagRequired
(
"symbol"
)
cmd
.
Flags
()
.
StringP
(
"totalSupply"
,
"m"
,
"0"
,
"total supply"
)
_
=
cmd
.
MarkFlagRequired
(
"totalSupply"
)
cmd
.
Flags
()
.
IntP
(
"decimal"
,
"d"
,
8
,
"decimal"
)
_
=
cmd
.
MarkFlagRequired
(
"decimal"
)
}
func
DeployBEP20
(
cmd
*
cobra
.
Command
,
_
[]
string
)
{
url
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr_ethereum"
)
deployerAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"deployAddr"
)
owner
,
_
:=
cmd
.
Flags
()
.
GetString
(
"owner"
)
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
totalSupply
,
_
:=
cmd
.
Flags
()
.
GetString
(
"totalSupply"
)
decimal
,
_
:=
cmd
.
Flags
()
.
GetInt
(
"decimal"
)
bnAmount
:=
big
.
NewInt
(
1
)
bnAmount
,
_
=
bnAmount
.
SetString
(
utils
.
TrimZeroAndDot
(
totalSupply
),
10
)
client
,
err
:=
ethclient
.
Dial
(
url
)
if
err
!=
nil
{
fmt
.
Println
(
"ethclient Dial error"
,
err
.
Error
())
return
}
symbol
=
strings
.
ToUpper
(
symbol
)
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
(
bep20
.
BEP20TokenABI
))
if
err
!=
nil
{
fmt
.
Println
(
"abi.JSON(strings.NewReader(erc20.ERC20ABI)) error"
,
err
.
Error
())
return
}
bin
:=
common
.
FromHex
(
bep20
.
BEP20TokenBin
)
BEP20OwnerAddr
:=
common
.
HexToAddress
(
owner
)
//constructor (string memory name_, string memory symbol_,uint256 totalSupply_, uint8 decimals_, address owner_) public {
tokenName
:=
symbol
+
" Token"
packdata
,
err
:=
parsed
.
Pack
(
""
,
tokenName
,
symbol
,
bnAmount
,
uint8
(
decimal
),
BEP20OwnerAddr
)
if
err
!=
nil
{
fmt
.
Println
(
"Pack error"
,
err
.
Error
())
return
}
BEP20Addr
:=
crypto
.
CreateAddress
(
common
.
HexToAddress
(
deployerAddr
),
startNonce
)
deployInfo
:=
DeployInfo
{
PackData
:
append
(
bin
,
packdata
...
),
ContractorAddr
:
BEP20Addr
,
Name
:
"BEP20: "
+
symbol
,
Nonce
:
startNonce
,
To
:
nil
,
}
infos
=
append
(
infos
,
&
deployInfo
)
fileName
:=
fmt
.
Sprintf
(
"deployBEP20%s.txt"
,
symbol
)
err
=
NewTxWrite
(
infos
,
common
.
HexToAddress
(
deployerAddr
),
url
,
fileName
)
if
err
!=
nil
{
fmt
.
Println
(
"NewTxWrite error"
,
err
.
Error
())
return
}
}
func
DeployERC20Cmd
()
*
cobra
.
Command
{
func
DeployERC20Cmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"create_erc20"
,
Use
:
"create_erc20"
,
...
...
plugin/dapp/cross2eth/boss4x/ethereum/offline/offline.go
View file @
1394bb36
...
@@ -34,6 +34,7 @@ func DeployOfflineContractsCmd() *cobra.Command {
...
@@ -34,6 +34,7 @@ func DeployOfflineContractsCmd() *cobra.Command {
CreateCmd
(),
//构造交易
CreateCmd
(),
//构造交易
CreateWithFileCmd
(),
CreateWithFileCmd
(),
DeployERC20Cmd
(),
DeployERC20Cmd
(),
DeployBEP20Cmd
(),
DeployTetherUSDTCmd
(),
DeployTetherUSDTCmd
(),
//CreateCfgAccountTxCmd(), // set_offline_addr 设置离线多签地址
//CreateCfgAccountTxCmd(), // set_offline_addr 设置离线多签地址
//SetupCmd(),
//SetupCmd(),
...
...
plugin/dapp/cross2eth/contracts/bep20/BEP20.sol
View file @
1394bb36
...
@@ -352,14 +352,24 @@ contract BEP20Token is Context, IBEP20, Ownable {
...
@@ -352,14 +352,24 @@ contract BEP20Token is Context, IBEP20, Ownable {
string private _symbol;
string private _symbol;
string private _name;
string private _name;
constructor() public {
// constructor() public {
_name = "BUSD Token";
// _name = "BUSD Token";
_symbol = "BUSD";
// _symbol = "BUSD";
_decimals = 18;
// _decimals = 18;
_totalSupply = 31000000000000000000000000;
// _totalSupply = 31000000000000000000000000;
_balances[msg.sender] = _totalSupply;
// _balances[msg.sender] = _totalSupply;
//
emit Transfer(address(0), msg.sender, _totalSupply);
// emit Transfer(address(0), msg.sender, _totalSupply);
// }
constructor (string memory name_, string memory symbol_,uint256 totalSupply_, uint8 decimals_, address owner_) public {
_name = name_;
_symbol = symbol_;
_decimals = decimals_;
_totalSupply = totalSupply_;
_balances[owner_] = totalSupply_;
emit Transfer(address(0), owner_, totalSupply_);
}
}
/**
/**
...
...
plugin/dapp/cross2eth/contracts/bep20/generated/bep20.go
View file @
1394bb36
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment