Bytecode deployment cheat-code
The Admin RPC methodtenderly_setCode lets you deploy arbitrary bytecode to an arbitrary address. This is useful for testing purposes, for instrumenting contracts that take part in the test.
When deploying modified bytecode, the verification information will no longer match and it will not be possible to access traces and debugger for target addresses.
#!/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