2

If I want to create a smart contract with an action 'Create Game' and on calling that action a new contract be formed, how is it possible?

1
  • I don't think setcode is in the available contract API so I don't think it's possible directly
    – confused00
    Commented Sep 11, 2018 at 14:00

2 Answers 2

1

You can't create a 'new' contract, but you can call another contract's function and create a new object in that contract to save the state.

You can refer to eosio.token inline functions get_balance/get_supply where both functions are accessible from any other contracts by just initializing eosio.token in your own contract.

edit: It is not possible to create an object in another contract as it will consume ram

0

Think of your contract as a factory. You keep a collection of games. Each game is an instance of a struct called game - it has all the state fields of a game. When someone creates a new game you just add one to the collection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.