Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
foundrytest
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
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
explorer-for-cmp20
foundrytest
Commits
a73bc41f
Commit
a73bc41f
authored
Jan 30, 2026
by
Developer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
c0b2be1d
Pipeline
#926
canceled with stages
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
13 deletions
+18
-13
deploy-local.sh
deploy-local.sh
+3
-0
DeployAll.s.sol
script/DeployAll.s.sol
+11
-7
DeployERC20.s.sol
script/DeployERC20.s.sol
+2
-3
DeployInternalTransfer.s.sol
script/DeployInternalTransfer.s.sol
+2
-3
No files found.
deploy-local.sh
View file @
a73bc41f
...
@@ -61,11 +61,14 @@ echo -e "${GREEN}✓ 编译成功${NC}"
...
@@ -61,11 +61,14 @@ echo -e "${GREEN}✓ 编译成功${NC}"
echo
""
echo
""
# 部署所有合约(使用 legacy 交易,禁用 EIP-1559)
# 部署所有合约(使用 legacy 交易,禁用 EIP-1559)
# --slow 参数会在发送每笔交易后等待确认
echo
-e
"
${
GREEN
}
[3/4] 部署合约到
$RPC_URL
...
${
NC
}
"
echo
-e
"
${
GREEN
}
[3/4] 部署合约到
$RPC_URL
...
${
NC
}
"
echo
-e
"
${
YELLOW
}
使用顺序模式:每笔交易等待确认后再发送下一笔
${
NC
}
"
forge script script/DeployAll.s.sol:DeployAll
\
forge script script/DeployAll.s.sol:DeployAll
\
--rpc-url
$RPC_URL
\
--rpc-url
$RPC_URL
\
--broadcast
\
--broadcast
\
--legacy
\
--legacy
\
--slow
\
-vvvv
-vvvv
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
...
...
script/DeployAll.s.sol
View file @
a73bc41f
...
@@ -9,10 +9,11 @@ contract DeployAll is Script {
...
@@ -9,10 +9,11 @@ contract DeployAll is Script {
function run() external {
function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
// 1. 部署ERC20代币(第一笔交易)
vm.startBroadcast(deployerPrivateKey);
vm.startBroadcast(deployerPrivateKey);
// 1. 部署ERC20代币
ERC20Token token = new ERC20Token("Test Token", "TST", 18, 1000000);
ERC20Token token = new ERC20Token("Test Token", "TST", 18, 1000000);
vm.stopBroadcast();
console.log("=== ERC20Token Deployed ===");
console.log("=== ERC20Token Deployed ===");
console.log("Address:", address(token));
console.log("Address:", address(token));
console.log("Name:", token.name());
console.log("Name:", token.name());
...
@@ -20,23 +21,26 @@ contract DeployAll is Script {
...
@@ -20,23 +21,26 @@ contract DeployAll is Script {
console.log("Total Supply:", token.totalSupply());
console.log("Total Supply:", token.totalSupply());
console.log("");
console.log("");
// 2. 部署内部转账合约
// 2. 部署内部转账合约(第二笔交易,等待上一笔确认)
vm.startBroadcast(deployerPrivateKey);
InternalTransfer transferContract = new InternalTransfer();
InternalTransfer transferContract = new InternalTransfer();
vm.stopBroadcast();
console.log("=== InternalTransfer Deployed ===");
console.log("=== InternalTransfer Deployed ===");
console.log("Address:", address(transferContract));
console.log("Address:", address(transferContract));
console.log("Owner:", transferContract.owner());
console.log("Owner:", transferContract.owner());
console.log("");
console.log("");
// 3. 进行一些初始化操作
// 3. 进行一些初始化操作
(第三笔交易,等待上一笔确认)
address testUser = 0x70997970C51812dc3A010C7d01b50e0d17dc79C8; // 测试账户
address testUser = 0x70997970C51812dc3A010C7d01b50e0d17dc79C8; // 测试账户
uint256 transferAmount = 10000 * 10**18;
uint256 transferAmount = 10000 * 10**18;
// 给测试账户转一些代币
vm.startBroadcast(deployerPrivateKey);
token.transfer(testUser, transferAmount);
token.transfer(testUser, transferAmount);
vm.stopBroadcast();
console.log("=== Initial Setup ===");
console.log("=== Initial Setup ===");
console.log("Transferred", transferAmount, "tokens to", testUser);
console.log("Transferred", transferAmount, "tokens to", testUser);
console.log("Test user balance:", token.balanceOf(testUser));
console.log("Test user balance:", token.balanceOf(testUser));
vm.stopBroadcast();
}
}
}
}
script/DeployERC20.s.sol
View file @
a73bc41f
...
@@ -13,11 +13,10 @@ contract DeployERC20 is Script {
...
@@ -13,11 +13,10 @@ contract DeployERC20 is Script {
// 部署ERC20代币,初始供应量1000000
// 部署ERC20代币,初始供应量1000000
ERC20Token token = new ERC20Token("Test Token", "TST", 18, 1000000);
ERC20Token token = new ERC20Token("Test Token", "TST", 18, 1000000);
vm.stopBroadcast();
console.log("ERC20Token deployed at:", address(token));
console.log("ERC20Token deployed at:", address(token));
console.log("Total Supply:", token.totalSupply());
console.log("Total Supply:", token.totalSupply());
console.log("Deployer Balance:", token.balanceOf(msg.sender));
console.log("Deployer Balance:", token.balanceOf(msg.sender));
vm.stopBroadcast();
}
}
}
}
script/DeployInternalTransfer.s.sol
View file @
a73bc41f
...
@@ -13,10 +13,9 @@ contract DeployInternalTransfer is Script {
...
@@ -13,10 +13,9 @@ contract DeployInternalTransfer is Script {
// 部署内部转账合约
// 部署内部转账合约
InternalTransfer transferContract = new InternalTransfer();
InternalTransfer transferContract = new InternalTransfer();
vm.stopBroadcast();
console.log("InternalTransfer deployed at:", address(transferContract));
console.log("InternalTransfer deployed at:", address(transferContract));
console.log("Owner:", transferContract.owner());
console.log("Owner:", transferContract.owner());
vm.stopBroadcast();
}
}
}
}
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