Smart contracts to manage funds and transactions data

22 Views Asked by At

so basically I created a smart contract in solidity which has features like

  1. deposit erc20 token
  2. withdraw er20 token
  3. balance of the user
  4. buyorder
  5. sellorder

It working as as expected with all the feature align..

But I want to divide it in two smart contract say contract users which will deal with

  1. deposit erc20 token
  2. withdraw er20 token
  3. balance of the user

and another contract say contract orders which will deal with 4. buyorder 5. sellorder

The problem I am facing is security concern. If someone put a buy/sell order his balance will be deduct/ credit. So how can I call a balanceOf function of the contract user to deduct/credit the funds to the address who called the function of the contract order.

** If I call the function of contract A from contract B, the msg.sender will be address of contract B.

If a address 0x1234 call the function buyorder in contractB, the functionB should call the balanceOf function of contract A and deduct the balance of the address 0x1234.

0

There are 0 best solutions below