I know that you can bill another user for storage but what if i want to bill another smart contract which in turn will then bill its users. Is it possible?
Yes, as @confused00 mentioned in his comment, you can bill the RAM storage to either the account of the current contract itself (
_self) or any account for which the transaction includes permissions. This means it's based on a per-transaction scheme, which means that for example:
randysubmits a transaction signed by his account for an action in
contract1can store something in DB billed to either
contract1sends an inline action to
contract2can store something billed to either
contract2or any of the permissions given in the inline action to it (
contract1 can decide what permissions to pass on to
contract2 in the inline action.
In the documentation for
emplace you can see there's a parameter for defining who is billed for the storage: https://developers.eos.io/eosio-cpp/reference#emplace
In the documentation for inline actions and permission levels you can see how to send actions and set the permissions: https://developers.eos.io/eosio-cpp/reference#structeosio_1_1permission__level
EDIT: Also more related information here: How to authorize inline action of another contract within a contract?