paritytech / substrate-contracts-node

Minimal Substrate node configured for smart contracts via pallet-contracts.
The Unlicense
124 stars 145 forks source link

Add a pallet to demonstrate calling into a contract #228

Closed ascjones closed 7 months ago

ascjones commented 7 months ago

An foundational step towards https://github.com/paritytech/ink/issues/1674, developing an API for calling into a contract from the runtime.

This PR

The next step (in progress) is to work and iterate on the ink API itself, which will involve an ink PR and a PR here to utilize the new API.

jasl commented 7 months ago

Do you think this PR can resolve my question? https://substrate.stackexchange.com/questions/10685/how-to-call-a-contract-from-pallet-with-specific-interface

I want to extend my pallet through the developers' uploaded contract, for example, For an NFT marketplace pallet, I want to allow NFT collection owners to register a few "hooks" (such as on_bought and on_sell) so they can have a restricted way to extend fixed pallet business logic. So, I want those contracts that serve as a hook, acquired to conform to specific interfaces, and in the pallet, I want to call the typed interface instead of a selector.

ascjones commented 7 months ago

Do you think this PR can resolve my question? https://substrate.stackexchange.com/questions/10685/how-to-call-a-contract-from-pallet-with-specific-interface

I want to extend my pallet through the developers' uploaded contract, for example, For an NFT marketplace pallet, I want to allow NFT collection owners to register a few "hooks" (such as on_bought and on_sell) so they can have a restricted way to extend fixed pallet business logic. So, I want those contracts that serve as a hook, acquired to conform to specific interfaces, and in the pallet, I want to call the typed interface instead of a selector.

Yes, you can use the technique I have used in this PR. I am currently working on a nicer API for this, but it is a few weeks away from being ready.

jasl commented 7 months ago

Do you think this PR can resolve my question? https://substrate.stackexchange.com/questions/10685/how-to-call-a-contract-from-pallet-with-specific-interface I want to extend my pallet through the developers' uploaded contract, for example, For an NFT marketplace pallet, I want to allow NFT collection owners to register a few "hooks" (such as on_bought and on_sell) so they can have a restricted way to extend fixed pallet business logic. So, I want those contracts that serve as a hook, acquired to conform to specific interfaces, and in the pallet, I want to call the typed interface instead of a selector.

Yes, you can use the technique I have used in this PR. I am currently working on a nicer API for this, but it is a few weeks away from being ready.

That's awesome! Will try when it's landing

ascjones commented 7 months ago

Superseded by https://github.com/paritytech/ink/pull/2189, it is more appropriate to live in that repo since that is where the API will live.

Polkadot-Forum commented 2 months ago

This pull request has been mentioned on Polkadot Forum. There might be relevant details there:

https://forum.polkadot.network/t/contracts-on-assethub-roadmap/9513/11