tenderly_setCode 让您可以将任意字节码部署到任意地址。这对于测试目的以及对参与测试的合约进行插桩很有用。
部署修改过的字节码后,验证信息将不再匹配,也无法访问目标地址的跟踪和 Debugger。
#!/bin/bash
# Define the Tenderly RPC URL
VIRTUAL_TESTNET_RPC="https://YOUR_VIRTUAL_TESTNET_RPC_URL" # Replace with the actual RPC
CONTRACT_ADDRESS="0x81a831281cb844cf383d5b7446048c33f8f61597" # Replace with the an arbitrary contract address
# Define the contract address and bytecode
BYTECODE="0x6080604052348015600f57600080fd5b506004361060325760003560e01c8063188ec356146037578063f2c9ecd814604b575b600080fd5b425b60405190815260200160405180910390f35b43603956fea2646970667358221220cf2559005e1cfe369d80627215e827ac118ec62d8642fc9962efa55315dd451b64736f6c63430008110033"
# Function to deploy the contract by setting the bytecode
set_code_response=$(curl -s -X POST \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "tenderly_setCode",
"params": ["'"$CONTRACT_ADDRESS"'", "'"$BYTECODE"'"],
"id": 1
}' "$VIRTUAL_TESTNET_RPC")
# Call the function from contract
eth_call_response=$(curl -s -X POST \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{
"to": "'"$CONTRACT_ADDRESS"'",
"data": "0x188ec356"
}, "latest"],
"id": 2
}' "$VIRTUAL_TESTNET_RPC")
echo $eth_call_response