मुख्य सामग्री पर जाएं
Admin RPC मेथड tenderly_setCode आपको किसी भी address पर arbitrary bytecode deploy करने देता है। यह testing उद्देश्यों के लिए उपयोगी है, टेस्ट में भाग लेने वाले contracts को instrument करने के लिए।
संशोधित bytecode deploy करते समय, verification जानकारी अब match नहीं करेगी और लक्षित addresses के लिए traces और 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