Skip to main content
deleted 39 characters in body
Source Link
Sky
  • 2.4k
  • 2
  • 8
  • 26

Here is a Solidity code for the New contract that can call the f1() function from your Old contract. Hope this helps. I tried to keep it as simple as possible.

    import "./Old.sol";    // You import the existing contract. 
        
        
            /**
            * The NEW contract will call the Old one
            */
        
          contract New {
          
               Old OLD; // Intitilize old contract variable (empty)
        
            /**
             * Set the address for Old contract (We call this function and enter the address of the OLD contract)
             */
            function setOldContractAddress(address addr) public {
                OLD = Old(addr);
            }
        
        
             /**
             * Function that allows us to call f1() from the Old contract
             */
            function callOLDcontract(string memory serialNumber, uint amount) public {
                OLD.f1();
             
                }
            
            }

Here is a Solidity code for the New contract that can call the f1() function from your Old contract. Hope this helps. I tried to keep it as simple as possible.

    import "./Old.sol";    // You import the existing contract. 
        
        
            /**
            * The NEW contract will call the Old one
            */
        
          contract New {
          
               Old OLD; // Intitilize old contract variable (empty)
        
            /**
             * Set the address for Old contract (We call this function and enter the address of the OLD contract)
             */
            function setOldContractAddress(address addr) public {
                OLD = Old(addr);
            }
        
        
             /**
             * Function that allows us to call f1() from the Old contract
             */
            function callOLDcontract(string memory serialNumber, uint amount) public {
                OLD.f1();
             
                }
            
            }

Here is a Solidity code for the New contract that can call the f1() function from your Old contract. Hope this helps. I tried to keep it as simple as possible.

    import "./Old.sol";    // You import the existing contract. 
        
        
            /**
            * The NEW contract will call the Old one
            */
        
          contract New {
          
               Old OLD; // Intitilize old contract variable (empty)
        
            /**
             * Set the address for Old contract (We call this function and enter the address of the OLD contract)
             */
            function setOldContractAddress(address addr) public {
                OLD = Old(addr);
            }
        
        
             /**
             * Function that allows us to call f1() from the Old contract
             */
            function callOLDcontract() public {
                OLD.f1();
             
                }
            
            }
Source Link
Sky
  • 2.4k
  • 2
  • 8
  • 26

Here is a Solidity code for the New contract that can call the f1() function from your Old contract. Hope this helps. I tried to keep it as simple as possible.

    import "./Old.sol";    // You import the existing contract. 
        
        
            /**
            * The NEW contract will call the Old one
            */
        
          contract New {
          
               Old OLD; // Intitilize old contract variable (empty)
        
            /**
             * Set the address for Old contract (We call this function and enter the address of the OLD contract)
             */
            function setOldContractAddress(address addr) public {
                OLD = Old(addr);
            }
        
        
             /**
             * Function that allows us to call f1() from the Old contract
             */
            function callOLDcontract(string memory serialNumber, uint amount) public {
                OLD.f1();
             
                }
            
            }