### Reactive Network RPC Methods Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/index.md Key RPC methods for the Reactive Network's Geth version. This documentation outlines the available methods for interacting with the network's RPC interface, essential for node operators and developers. ```APIDOC RNK RPC Methods: This section details the specific RPC methods available in the Reactive Network's Geth implementation. These methods are crucial for querying network state, submitting transactions, and managing nodes. Example Methods (Illustrative - actual methods may vary): eth_getBlockByNumber(blockNumber: "latest" | "earliest" | "pending" | hex): - Description: Returns a block given the block number. - Parameters: - blockNumber: The block number, or a string representing a block number (e.g., "latest"). - Returns: A block object, or null if the block is not found. eth_sendRawTransaction(hexTransaction: hex): - Description: Submits a pre-signed Ethereum transaction to the network. - Parameters: - hexTransaction: The signed transaction in hexadecimal format. - Returns: The transaction hash. eth_call(transactionObject: object, blockId: "latest" | "earliest" | "pending" | hex): - Description: Executes a message call immediately without creating a transaction on the blockchain. - Parameters: - transactionObject: An object containing transaction details (from, to, gas, gasPrice, value, data). - blockId: The block identifier to execute the call against. - Returns: The output of the call. Note: Refer to the official Reactive Network documentation for a complete and up-to-date list of supported RPC methods and their detailed specifications. ``` -------------------------------- ### Install Dependencies (Yarn) Source: https://github.com/reactive-network/documentation/blob/main/README.md Installs project dependencies using Yarn. This is the first step before running any other commands. ```bash yarn ``` -------------------------------- ### Install Reactive Library Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/reactive-lib.mdx Command to install the Reactive Library using forge. This is the initial step to integrate the library into your project. ```bash forge install Reactive-Network/reactive-lib ``` -------------------------------- ### Solidity by Example Resource Source: https://github.com/reactive-network/documentation/blob/main/docs/education/introduction/prerequisites.md Provides hands-on examples for learning Solidity, from basics to advanced topics. ```URL https://solidity-by-example.org/ ``` -------------------------------- ### Constructor Subscription Example Source: https://github.com/reactive-network/documentation/blob/main/docs/education/module-1/subscriptions.md An example of how to subscribe to events within a contract's constructor. It shows the initialization of a system contract and the subscription call with specific parameters. ```solidity // State specific to reactive network instance of the contract address private _callback; // State specific to ReactVM instance of the contract uint256 public counter; constructor( address _service, address _contract, uint256 topic_0, address callback ) payable { service = ISystemContract(payable(_service)); if (!vm) { service.subscribe( CHAIN_ID, _contract, topic_0, REACTIVE_IGNORE, REACTIVE_IGNORE, REACTIVE_IGNORE ); } _callback = callback; } ``` -------------------------------- ### Example: Verify and Deploy Contract with Constructor Arguments Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/reactive-smart-contracts.md An example demonstrating how to verify and deploy a contract using `forge create` with broadcast, RPC URL, private key, chain ID, value, and constructor arguments. This command submits the contract source to Sourcify immediately after deployment. ```bash forge create \ --broadcast \ --rpc-url $REACTIVE_RPC_URL \ --private-key $REACTIVE_PRIVATE_KEY \ --chain-id $REACTIVE_CHAIN_ID \ --value 0.01ether \ --verify \ --verifier sourcify \ --verifier-url https://sourcify.rnk.dev/ \ src/.../MyContract.sol:MyContract \ --constructor-args \ $ARGUMENT_1 \ $ARGUMENT_2 \ $ARGUMENT_3 \ # ...add more as needed ``` -------------------------------- ### Start Local Development Server (Yarn) Source: https://github.com/reactive-network/documentation/blob/main/README.md Starts a local development server for the Docusaurus website. Changes are reflected live without a server restart. ```bash yarn start ``` -------------------------------- ### Solidity Subscription Example in Constructor Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/subscriptions.md Demonstrates how to subscribe to events within the constructor of a Solidity smart contract. It initializes system contract interaction and sets up a subscription with specific filtering criteria. Requires implementation of IReactive, AbstractReactive, and ISystemContract interfaces. ```solidity uint256 public originChainId; uint256 public destinationChainId; uint64 private constant GAS_LIMIT = 1000000; address private callback; constructor( address _service, uint256 _originChainId, uint256 _destinationChainId, address _contract, uint256 _topic_0, address _callback ) payable { service = ISystemContract(payable(_service)); originChainId = _originChainId; destinationChainId = _destinationChainId; callback = _callback; if (!vm) { service.subscribe( originChainId, _contract, _topic_0, REACTIVE_IGNORE, REACTIVE_IGNORE, REACTIVE_IGNORE ); } } ``` -------------------------------- ### BasicDemoReactiveContract.sol Example Source: https://github.com/reactive-network/documentation/blob/main/docs/education/use-cases/remix-ide-demo.mdx A Solidity smart contract example for demonstrating Reactive Network functionality. This contract is intended to be compiled and deployed using Remix. ```Solidity pragma solidity ^0.8.0; import "@reactive-network/contracts/interfaces/IReactiveContract.sol"; contract BasicDemoReactiveContract is IReactiveContract { event MessageReceived(address indexed sender, string message); function receiveMessage(address _origin, bytes calldata _data) external override { emit MessageReceived(_origin, abi.decode(_data, (string))); } } ``` -------------------------------- ### Ethereum EVM Illustrated Guide Source: https://github.com/reactive-network/documentation/blob/main/docs/education/introduction/prerequisites.md Offers a visual and detailed explanation of the Ethereum Virtual Machine's inner workings. ```URL https://takenobu-hs.github.io/downloads/ethereum_evm_illustrated.pdf ``` -------------------------------- ### Chainlink Oracle Integration Example Source: https://github.com/reactive-network/documentation/blob/main/docs/education/module-1/how-oracles-work.md Illustrates how Chainlink can be used to fetch external data for smart contracts, enabling real-time interaction with off-chain events. ```APIDOC Chainlink Oracle Integration: Functionality: Fetching external data (e.g., price feeds, weather reports) onto the blockchain. Use Case: Enabling smart contracts to react to real-world events and data. Example Applications: - DeFi Platforms: Managing lending rates, liquidations, and asset swaps using price feed oracles. - Insurance: Triggering payouts based on verifiable off-chain events (e.g., natural disasters). - Online Betting: Providing outcomes of sporting events to trustless betting smart contracts. ``` -------------------------------- ### Uniswap V2 Swap Function Example Source: https://github.com/reactive-network/documentation/blob/main/docs/education/module-2/how-uniswap-works.md Demonstrates a simplified swap function within a Uniswap V2 smart contract, illustrating how token exchanges are managed based on the constant product formula. This example highlights the core logic for swapping tokens in a liquidity pool. ```Solidity pragma solidity ^0.8.0; interface IERC20 { function transfer(address recipient, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function balanceOf(address account) external view returns (uint256); } contract UniswapV2Pair { IERC20 public token0; IERC20 public token1; uint256 public reserve0; uint256 public reserve1; constructor(address _token0, address _token1) { token0 = IERC20(_token0); token1 = IERC20(_token1); } function _mint(address to, uint256 amount) internal { // Implementation for minting LP tokens } function _update(uint256 reserve0, uint256 reserve1, uint256 reserve0Old, uint256 reserve1Old) internal { // Implementation for updating reserves and emitting events } function mint(address to) public returns (uint256 liquidity) { // Implementation for adding liquidity return 0; } function burn(address to) public returns (uint256 amount0, uint256 amount1) { // Implementation for removing liquidity return (0, 0); } function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external { require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: MUST_Provide_Output_Amount'); (uint reserve0, uint reserve1) = (reserve0, reserve1); require(amount0Out < reserve0 && amount1Out < reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY'); uint amount0In = 0; uint amount1In = 0; if (amount0Out > 0) amount0In = _getAmount0In(amount0Out, reserve0, reserve1); if (amount1Out > 0) amount1In = _getAmount1In(amount1Out, reserve0, reserve1); require(amount0In == token0.transferFrom(msg.sender, address(this), amount0In), 'UniswapV2: TRANSFER_FAILED'); require(amount1In == token1.transferFrom(msg.sender, address(this), amount1In), 'UniswapV2: TRANSFER_FAILED'); if (amount0Out > 0) IERC20(token0).transfer(to, amount0Out); if (amount1Out > 0) IERC20(token1).transfer(to, amount1Out); } function _getAmount0In(uint amount0Out, uint reserve0, uint reserve1) internal pure returns (uint amount0In) { require(amount0Out > 0, 'UniswapV2: AMOUNT_OUT_ZERO'); return (reserve0 * amount0Out) / (reserve1 - amount0Out); } function _getAmount1In(uint amount1Out, uint reserve0, uint reserve1) internal pure returns (uint amount1In) { require(amount1Out > 0, 'UniswapV2: AMOUNT_OUT_ZERO'); return (reserve1 * amount1Out) / (reserve0 - amount1Out); } function _getAmount0For1(uint amount1In, uint reserve0, uint reserve1) internal pure returns (uint amount0Out) { require(amount1In > 0, 'UniswapV2: AMOUNT_IN_ZERO'); return (amount0Out * reserve1) / (reserve0 + amount0Out); } function _getAmount1For0(uint amount0In, uint reserve0, uint reserve1) internal pure returns (uint amount1Out) { require(amount0In > 0, 'UniswapV2: AMOUNT_IN_ZERO'); return (reserve1 * amount0In) / (reserve0 + amount0In); } function skim(address to) external { // Implementation for skimming excess tokens } function sync() external { // Implementation for syncing reserves } function initialize(address, address) external { // Implementation for initialization } } ``` -------------------------------- ### RNK RPC Methods Documentation Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/rnk-rpc-methods.md Provides documentation for Reactive Network's Geth version RPC methods, including transaction retrieval and log access. Covers method signatures, parameters, cURL examples, and JSON responses. ```APIDOC rnk_getTransactionByHash: Description: Returns the details of a transaction for the specified ReactVM ID and transaction hash. Parameters: rvmId: DATA, 20 Bytes — The ReactVM ID associated with the transaction. txHash: DATA, 32 Bytes — The hash of the transaction to retrieve. cURL Example: curl --location 'https://lasna-rpc.rnk.dev/' \ --header 'Content-Type: application/json' \ --data '{ \ "jsonrpc": "2.0", \ "method": "rnk_getTransactionByHash", \ "params": [ \ "0xa7d9aa89cbcd216900a04cdc13eb5789d643176a", \ "0xe32b9f60321f7a83ef9dda5daf8cf5b2f5cd523156ee484f417d62d84d1e3044" \ ], \ "id": 1 \ }' | jq Response Fields: hash (string): The transaction hash. number (string): The transaction number (hex-encoded). time (uint64): The timestamp of when the transaction occurred. root (string): The Merkle root associated with the transaction. limit (uint32): The maximum gas limit set for the transaction. used (uint32): The gas used by the transaction. type (uint8): The transaction type (0 for Legacy, 1 for AccessList, 2 for DynamicFee, 3 for Blob, 4 for SetCode). status (uint8): The status of the transaction (1 for Success, 0 for Failure). from (string): The transaction initiator. to (string): The recipient address. createContract (bool): Indicates whether a contract was created during this transaction. sessionId (uint64): The block number where the transaction is located (hex-encoded). refChainId (uint32): The origin chain ID. refTx (string): The hash of the origin chain transaction that triggered this one. refEventIndex (uint32): The origin chain event opcode (0 for LOG0, 1 for LOG1, 2 for LOG2, 3 for LOG3, 4 for LOG4). data (string): The encoded transaction data in hexadecimal format. rData (string): Additional response data in hexadecimal format (if any). rnk_getTransactionByNumber: Description: Returns the details of a transaction based on its sequence number within the specified ReactVM. Parameters: rvmId: DATA, 20 Bytes — The ReactVM ID associated with the transaction. txNumber: HEX — The sequence number of the transaction to retrieve. cURL Example: curl --location 'https://lasna-rpc.rnk.dev/' \ --header 'Content-Type: application/json' \ --data '{ \ "jsonrpc": "2.0", \ "method": "rnk_getTransactionByNumber", \ "params": [ \ "0xa7d9aa89cbcd216900a04cdc13eb5789d643176a", \ "0x9" \ ], \ "id": 1 \ }' | jq ``` -------------------------------- ### Hyperlane Demo Deployment and Messaging Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/hyperlane.mdx This snippet provides a link to a demo showcasing how to deploy contracts and send messages using Hyperlane mailboxes. It serves as a practical guide for implementing cross-chain communication with Hyperlane. ```javascript https://github.com/Reactive-Network/reactive-smart-contract-demos/tree/main/src/demos/hyperlane ``` -------------------------------- ### Basic Reactive Demo react() Function Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/events-and-callbacks.md An example implementation of the react() function for a basic reactive contract. It emits an Event with log details and a counter, and conditionally emits a Callback event if the log data meets a certain threshold. ```solidity // State specific to reactive network instance of the contract address private _callback; // State specific to ReactVM instance of the contract uint256 public counter; function react(LogRecord calldata log) external vmOnly { emit Event( log.chain_id, log._contract, log.topic_0, log.topic_1, log.topic_2, log.topic_3, log.data, ++counter ); if (log.topic_3 >= 0.01 ether) { bytes memory payload = abi.encodeWithSignature("callback(address)", address(0)); emit Callback(log.chain_id, _callback, GAS_LIMIT, payload); } } ``` -------------------------------- ### rnk_getTransactionByHash JSON Response Example Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/rnk-rpc-methods.md Example JSON response structure for the rnk_getTransactionByHash RPC method, detailing transaction attributes. ```json { "jsonrpc": "2.0", "id": 1, "result": { "hash": "0xe32b9f60321f7a83ef9dda5daf8cf5b2f5cd523156ee484f417d62d84d1e3044", "number": "0x9", "time": 1753427529, "root": "0x8df166bb5c9843696457dbdc5ab20ca1ab9acdd8703b6f1fd1f51766f34fad7d", "limit": 900000, "used": 47429, "type": 2, "status": 1, "from": "0xa7d9aa89cbcd216900a04cdc13eb5789d643176a", "to": "0x6ba34385d9018cfa3341db62b68b5a55839fe71f", "createContract": false, "sessionId": 109252, "refChainId": 11155111, "refTx": "0x52daf0ff44c50da56024f02530ba70fcf653ad11dadb1788b24b20fc824520f5", "refEventIndex": 328, "data": "0x0d152c2c00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000aa36a7000000000000000000000000c156ad2846d093e0ce4d31cf6d780357e9675dce8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925000000000000000000000000a7d9aa89cbcd216900a04cdc13eb5789d643176a00000000000000000000000065a9b8b03a2ef50356104cb594ba2c91223973de00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000086da6000000000000000000000000000000000000000000000000000000000000000034570ac2a3bbfa2809982e69218a745aa83e1bff79b54e2a2ce10e5d6d4c5c00a52daf0ff44c50da56024f02530ba70fcf653ad11dadb1788b24b20fc824520f50000000000000000000000000000000000000000000000000000000000000148000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003e8", "rData": "0x" } } ``` -------------------------------- ### Command Line Basics Course Source: https://github.com/reactive-network/documentation/blob/main/docs/education/introduction/prerequisites.md A course to learn the fundamentals of using the command line interface. ```URL https://www.codecademy.com/learn/learn-the-command-line ``` -------------------------------- ### Constructor - Reactive Network Source: https://github.com/reactive-network/documentation/blob/main/docs/education/module-2/basic-reactive-functions.md Initializes the contract with Uniswap V2 pair, stop-order contract, client, token selection, coefficient, and threshold. Subscribes to relevant events if not in a reactVM instance. ```solidity constructor( address _pair, address _stop_order, address _client, bool _token0, uint256 _coefficient, uint256 _threshold ) payable { triggered = false; done = false; pair = _pair; stop_order = _stop_order; client = _client; token0 = _token0; coefficient = _coefficient; threshold = _threshold; if (!vm) { service.subscribe( SEPOLIA_CHAIN_ID, pair, UNISWAP_V2_SYNC_TOPIC_0, REACTIVE_IGNORE, REACTIVE_IGNORE, REACTIVE_IGNORE ); service.subscribe( SEPOLIA_CHAIN_ID, stop_order, STOP_ORDER_STOP_TOPIC_0, REACTIVE_IGNORE, REACTIVE_IGNORE, REACTIVE_IGNORE ); } } ``` -------------------------------- ### Pro Git Book Resource Source: https://github.com/reactive-network/documentation/blob/main/docs/education/introduction/prerequisites.md A concise and practical introduction to Git for version control. ```URL https://git-scm.com/book/en/v2 ``` -------------------------------- ### Constructor for Reactive Network Contract Source: https://github.com/reactive-network/documentation/blob/main/docs/education/module-1/subscriptions.md Initializes the contract by setting the owner, associating with the ApprovalService, and subscribing to relevant events if not in a VM environment. It requires an ApprovalService instance. ```solidity constructor( ApprovalService service_ ) payable { owner = msg.sender; approval_service = service_; if (!vm) { service.subscribe( SEPOLIA_CHAIN_ID, address(approval_service), SUBSCRIBE_TOPIC_0, REACTIVE_IGNORE, REACTIVE_IGNORE, REACTIVE_IGNORE ); service.subscribe( SEPOLIA_CHAIN_ID, address(approval_service), UNSUBSCRIBE_TOPIC_0, REACTIVE_IGNORE, REACTIVE_IGNORE, REACTIVE_IGNORE ); } } ``` -------------------------------- ### rnk_getTransactionByNumber cURL Request Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/rnk-rpc-methods.md Example cURL command to retrieve transaction details by its sequence number within a specified ReactVM. ```bash curl --location 'https://lasna-rpc.rnk.dev/' \ --header 'Content-Type: application/json' \ --data '{ "jsonrpc": "2.0", "method": "rnk_getTransactionByNumber", "params": [ "0xa7d9aa89cbcd216900a04cdc13eb5789d643176a", "0x9" ], "id": 1 }' | jq ``` -------------------------------- ### rnk_getTransactionByHash cURL Request Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/rnk-rpc-methods.md Example cURL command to fetch transaction details by hash from a Reactive Network RPC endpoint. ```bash curl --location 'https://lasna-rpc.rnk.dev/' \ --header 'Content-Type: application/json' \ --data '{ "jsonrpc": "2.0", "method": "rnk_getTransactionByHash", "params": [ "0xa7d9aa89cbcd216900a04cdc13eb5789d643176a", "0xe32b9f60321f7a83ef9dda5daf8cf5b2f5cd523156ee484f417d62d84d1e3044" ], "id": 1 }' | jq ``` -------------------------------- ### rnk_getTransactions API Call Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/rnk-rpc-methods.md Shows how to use the rnk_getTransactions method to fetch a range of transactions from a ReactVM, specifying the starting transaction number and a limit. ```bash curl --location 'https://lasna-rpc.rnk.dev/' \ --header 'Content-Type: application/json' \ --data '{ \ "jsonrpc": "2.0", \ "method": "rnk_getTransactions", \ "params": [ \ "0xA7D9AA89cbcd216900a04Cdc13eB5789D643176a", \ "0x9", \ "0x1" \ ], \ "id": 1 \ }' | jq ``` -------------------------------- ### AbstractReactive: Constructor and Service Initialization Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/reactive-lib.mdx The constructor initializes the `vendor` and `service` addresses to `SERVICE_ADDR` and authorizes `SERVICE_ADDR` as a sender. It also calls `detectVm()` to set the operational mode. ```solidity constructor() { vendor = service = SERVICE_ADDR; addAuthorizedSender(address(SERVICE_ADDR)); detectVm(); } ``` -------------------------------- ### Retrieve Contract Bytecode Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/rnk-rpc-methods.md This snippet demonstrates a JSON-RPC request to get the bytecode of a smart contract. The response contains the contract's bytecode in hexadecimal format. ```json { "jsonrpc": "2.0", "id": 1, "result": "0x60806040526004361061007e575f3560e01c80638456cb591161004d5780638456cb591461010757806396f90b451461011d578063995e4b9814610147578063c290d6911461017157610085565b806303ac52b314610089578063046f7da2146100b35780630d152c2c146100c95780637a90b990146100f157610085565b3661008557005b5f5ffd5b348015610094575f5ffd5b5061009d610199565b6040516100aa9190610cb0565b60405180910390f35b3480156100be575f5ffd5b506100c761019f565b005b3480156100d4575f5ffd5b506100ef60048036038101906100ea9190610cf4565b610458565b005b3480156100fc575f5ffd5b5061010561059d565b005b348015610112575f5ffd5b5061011b610665565b005b348015610128575f5ffd5b50610131610920565b60405161013e9190610cb0565b60405180910390f35b348015610152575f5ffd5b5061015b610929565b6040516101689190610cb0565b60405180910390f35b34801561017c575f5ffd5b5061019760048036038101906101929190610d65565b61092f565b005b60055481565b60025f9054906101000a900460ff16156101ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101e590610dea565b60405180910390fd5b60035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161027490610e52565b60405180910390fd5b600360149054906101000a900460ff166102cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102c390610eba565b60405180910390fd5b5f6102d56109c5565b90505f5f90505b8151811461043a57600260019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16635a6aced083838151811061033557610334610ed8565b5b60200260200101515f015184848151811061035357610352610ed8565b5b60200260200101516020015185858151811061037257610371610ed8565b5b60200260200101516040015186868151811061039157610390610ed8565b5b6020026020010151606001518787815181106103b0576103af610ed8565b5b6020026020010151608001518888815181106103cf576103ce610ed8565b5b602002602001015160a001516040518763ffffffff1660e01b81526004016103fc96959493929190610f44565b5f604051808303815f87803b158015610413575f5ffd5b505af1158015610425573d5f5f3e3d5ffd5b505050508061043390610fd0565b90506102dc565b505f600360146101000a81548160ff02191690831515021790555050565b60025f9054906101000a900460ff166104a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161049d90611061565b60405180910390fd5b60045481604001350361059a5743600581905550620f424067ffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16467f8dd725fa9d6cd150017ab9e60318d40616439424e2fade9c1c58854950917dfc6040516024016040516020818303038152906040527f083b2732000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161059191906110ef565b60405180910390a45b50565b5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639b6c56ec306040518263ffffffff1660e01b81526004016105f7919061110f565b602060405180830381865afa158015610612573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610636919061113c565b90506106625f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682610b0b565b50565b60025f9054906101000a900460ff16156106b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106ab90610dea565b60405180910390fd5b60035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610743576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161073a90610e52565b60405180910390fd5b600360149054906101000a900460ff1615610793576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078a906111b1565b60405180910390fd5b5f61079c6109c5565b90505f5f90505b8151811461090157600260019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632f8073368383815181106107fc576107fb610ed8565b5b60200260200101515f015184848151811061081a57610819610ed8565b5b60200260200101516020015185858151811061083957610838610ed8565b5b60200260200101516040015186868151811061085857610857610ed8565b5b60200260200101516060015187878151811061087757610876610ed8565b5b60200260200101516080015188888151811061089657610895610ed8565b5b602002602001015160a001516040518763ffffffff1660e01b81526004016108c396959493929190610f44565b5f604051808303815f87803b1580156108da575f5ffd5b505af11580156108ec573d5f5f3e3d5ffd5b50505050806108fa90610fd0565b90506107a3565b506001600360146101000a81548160ff02191690831515021790555050565b5f600554905090565b60045481565b60015f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526 ``` -------------------------------- ### Deploy Website (Yarn) Source: https://github.com/reactive-network/documentation/blob/main/README.md Deploys the Docusaurus website. Supports deployment using SSH or by specifying a GitHub username for pushing to the 'gh-pages' branch. ```bash USE_SSH=true yarn deploy ``` ```bash GIT_USER= yarn deploy ``` -------------------------------- ### Solidity Contract Initialization for Approval Listener Source: https://github.com/reactive-network/documentation/blob/main/docs/education/module-1/subscriptions.md Shows the import statements, constant declarations, and state variable initializations for an ApprovalListener contract. It defines chain IDs, event topics, gas limits, and service instances required for reactive programming. ```solidity pragma solidity >=0.8.0; import '../../../lib/reactive-lib/src/abstract-base/AbstractReactive.sol'; import './ApprovalService.sol'; contract ApprovalListener is AbstractReactive { uint256 private constant REACTIVE_CHAIN_ID = 0x512578; uint256 private constant SEPOLIA_CHAIN_ID = 11155111; uint256 private constant SUBSCRIBE_TOPIC_0 = 0x1aec2cf998e5b9daa15739cf56ce9bb0f29355de099191a2118402e5ac0805c8; uint256 private constant UNSUBSCRIBE_TOPIC_0 = 0xeed050308c603899d7397c26bdccda0810c3ccc6e9730a8a10c452b522f8edf4; uint256 private constant APPROVAL_TOPIC_0 = 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925; uint64 private constant CALLBACK_GAS_LIMIT = 1000000; address private owner; ApprovalService private approval_service; ``` -------------------------------- ### Foundry Broadcast Flag Error Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/reactive-smart-contracts.md This Go error message indicates an unexpected argument '--broadcast' when using `forge create`. It suggests removing the `--broadcast` flag from the command if your Foundry version or setup does not support it. ```go error: unexpected argument '--broadcast' found ``` -------------------------------- ### Deploy Origin Contract with Remix Source: https://github.com/reactive-network/documentation/blob/main/docs/education/use-cases/remix-ide-demo.mdx Steps to compile and deploy the BasicDemoL1Contract.sol using Remix IDE and MetaMask. Requires selecting the correct origin chain and copying the deployed contract address. ```solidity 1. Open BasicDemoL1Contract.sol in Remix. 2. Compile the contract. 3. Deploy the contract on any supported origin chain. - Select 'Injected Provider — MetaMask' as your environment in Remix. - Click 'Deploy' and confirm the transaction in MetaMask. - Copy the deployed contract address for the reactive contract. ``` -------------------------------- ### EVM Events Explanation Source: https://github.com/reactive-network/documentation/blob/main/docs/education/introduction/prerequisites.md Detailed explanation of how EVM events work, their logging, and interaction. ```Markdown Link ../module-1/how-events-work.md ``` -------------------------------- ### Sepolia Faucet for Test ETH Source: https://github.com/reactive-network/documentation/blob/main/docs/education/introduction/prerequisites.md Obtain testnet ETH for the Sepolia network to interact with Ethereum. ```URL https://www.alchemy.com/faucets/ethereum-sepolia ``` -------------------------------- ### Uniswap Stop Order Demo Callback Emission Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/events-and-callbacks.md An example of how to emit the Callback event in the Uniswap Stop Order Demo. It constructs a payload with encoded function signature and parameters for a stop order and specifies the destination chain and gas limit. ```solidity bytes memory payload = abi.encodeWithSignature( "stop(address,address,address,bool,uint256,uint256)", address(0), pair, client, token0, coefficient, threshold ); emit Callback(chain_id, stop_order, CALLBACK_GAS_LIMIT, payload); ``` -------------------------------- ### Reactive Network Basic Demo Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/demos.md Demonstrates monitoring logs from L1 contracts and initiating calls back to L1 contracts using the Reactive Network. It involves three smart contracts: BasicDemoL1Contract.sol, BasicDemoL1Callback.sol, and BasicDemoReactiveContract.sol. ```solidity /* BasicDemoL1Contract.sol: Origin chain contract BasicDemoL1Callback.sol: Destination chain contract BasicDemoReactiveContract.sol: Reactive contract */ ``` -------------------------------- ### Build Static Website (Yarn) Source: https://github.com/reactive-network/documentation/blob/main/README.md Generates the static content for the website into the 'build' directory. This output can be hosted on any static hosting service. ```bash yarn build ``` -------------------------------- ### Deposit to Callback Contract via Callback Proxy Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/economy.md Shows how to fund a callback contract using the callback proxy. The sender (EOA) covers the fee, and the proxy handles debt settlement automatically. ```bash cast send --rpc-url $DESTINATION_RPC --private-key $DESTINATION_PRIVATE_KEY $CALLBACK_PROXY_ADDR "depositTo(address)" $CALLBACK_ADDR --value 0.1ether ``` -------------------------------- ### Reactive Smart Contract Execution Flow Source: https://github.com/reactive-network/documentation/blob/main/docs/education/module-2/basic-reactive-functions.md Details the lifecycle of the reactive smart contract, from initialization and event monitoring to stop order activation and completion. ```Solidity contract ReactiveStopOrder { // Contract variables and event declarations would go here // Initialization: Subscribe to events function initialize() public { // Subscribe to Uniswap V2 Sync events // Subscribe to Stop Order Callback contract events } // Event Monitoring: Listen for Sync and Stop events function react(eventData) public { // Monitor Uniswap V2 pool reserve changes via Sync events // Track order execution via Stop events from the stop-order contract } // Stop Order Activation: Trigger stop order when price hits threshold function below_threshold(eventData) internal returns (bool) { // Check if pool price meets the stop order threshold // If true, initiate stop order via callback function return true; // Placeholder } // Completion: Capture Stop event to mark process completion // ... } ``` -------------------------------- ### Deposit to RVM Contract via System Contract Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/economy.md Explains how to fund an RVM contract by depositing through the system contract. This method automatically settles any debt, eliminating the need for a separate `coverDebt()` call. ```bash cast send --rpc-url $REACTIVE_RPC --private-key $REACTIVE_PRIVATE_KEY $SYSTEM_CONTRACT_ADDR "depositTo(address)" $CONTRACT_ADDR --value 0.1ether ``` -------------------------------- ### Approval Magic Demo Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/demos.md Demonstrates automated token approvals and cross-chain exchanges using reactive and subscription-based smart contracts. Key contracts include ApprovalService.sol, ApprovalListener.sol, and others for token initialization, exchanges, and swaps. ```solidity /* ApprovalService.sol: Manages subscriptions ApprovalListener.sol: Handles reactive events Additional contracts for token initialization, exchanges, and swaps */ ``` -------------------------------- ### Deploy Destination Contract with Remix Source: https://github.com/reactive-network/documentation/blob/main/docs/education/use-cases/remix-ide-demo.mdx Instructions for compiling and deploying the BasicDemoL1Callback.sol using Remix IDE and MetaMask. Requires specifying transaction value and a callback proxy address. ```solidity 1. Open BasicDemoL1Callback.sol in Remix. 2. Compile the contract. 3. Deploy the contract on any supported destination chain. - Select 'Injected Provider — MetaMask' as your environment in Remix. - Provide 0.01 Ether as transaction value and a unique callback proxy address. - Click 'Deploy' and confirm the transaction in MetaMask. - Copy the deployed contract address for the reactive contract. ``` -------------------------------- ### IPayer Interface Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/reactive-lib.mdx Defines the minimal contract for managing payments. It includes functions to initiate payments and accept Ether. ```solidity interface IPayer { function pay(uint256 amount) external; receive() external payable; } ``` -------------------------------- ### AbstractCallback Constructor Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/reactive-lib.mdx The constructor for AbstractCallback initializes the `rvm_id` with the deploying address and sets the `vendor` by interacting with AbstractPayer. It also authorizes the callback sender. ```solidity constructor(address _callback_sender) { rvm_id = msg.sender; vendor = IPayable(payable(_callback_sender)); addAuthorizedSender(_callback_sender); } ``` -------------------------------- ### Uniswap V2 Stop Order Reactive Contract Events and Imports Source: https://github.com/reactive-network/documentation/blob/main/docs/education/module-2/basic-reactive-functions.md Defines event declarations for logging and tracking operations, imports necessary interfaces and abstract base contracts for reactive functionality, and includes a struct for reserves. ```solidity // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.0; import '../../../lib/reactive-lib/src/interfaces/IReactive.sol'; import '../../../lib/reactive-lib/src/abstract-base/AbstractReactive.sol'; struct Reserves { uint112 reserve0; uint112 reserve1; } contract UniswapDemoStopOrderReactive is IReactive, AbstractReactive { event Subscribed( address indexed service_address, address indexed _contract, uint256 indexed topic_0 ); event VM(); event AboveThreshold( uint112 indexed reserve0, uint112 indexed reserve1, uint256 coefficient, uint256 threshold ); event CallbackSent(); event Done(); ``` -------------------------------- ### System Contract Overview Source: https://github.com/reactive-network/documentation/blob/main/docs/docs/reactive-lib.mdx The System Contract manages payments, access control (whitelisting/blacklisting), and cron events for the Reactive Network. It allows for time-based automation through block interval triggers. ```APIDOC System Contract: - Manages service payments for reactive contracts. - Handles contract access control (whitelisting/blacklisting). - Triggers periodic block interval actions via cron events. Cron Functionality: - Emits Cron events at fixed block intervals. - Nodes listen for these signals to invoke cron functions. - Simplifies automated workflows and on-chain triggers. - Only authorized validator root addresses can trigger cron functions. - `cron()` function emits `Cron` events based on block number divisibility. - `Cron` event parameter: `number` (current block number). ``` -------------------------------- ### Subscribe to All Events from a Specific Contract Source: https://github.com/reactive-network/documentation/blob/main/docs/education/module-1/subscriptions.md Demonstrates subscribing to all events originating from a particular contract address. It uses wildcard values for topics. ```solidity service.subscribe(CHAIN_ID, 0x7E0987E5b3a30e3f2828572Bb659A548460a3003, REACTIVE_IGNORE, REACTIVE_IGNORE, REACTIVE_IGNORE, REACTIVE_IGNORE) ``` -------------------------------- ### Reactive Contract Deployment Parameters Source: https://github.com/reactive-network/documentation/blob/main/docs/education/use-cases/remix-ide-demo.mdx Parameters required for deploying a Reactive Contract in Remix. These include system contract addresses, chain identifiers, and event signatures. ```APIDOC ReactiveContractDeployment: _service: string - The Reactive network system contract address. - Example: "0x0000000000000000000000000000000000fffFfF" _originChainId: number - The origin chain ID. - Reference: [Origins & Destinations](https://dev.reactive.network/origins-and-destinations#testnet-chains) _destinationChainId: number - The destination chain ID. - Reference: [Origins & Destinations](https://dev.reactive.network/origins-and-destinations#testnet-chains) _contract: string - The origin chain contract address. topic_0: string - The `Received` event signature on the origin chain contract. - Example: "0x8cabf31d2b1b11ba52dbb302817a3c9c83e4b2a5194d35121ab1354d69f6a4cb" _callback: string - The destination chain contract address. ```