Demo the "pull dependencies" workflow provided by dfx
.
The example project demonstrates how does an application canister pull its dependency from mainnet and integrate with it locally.
- Declare the pull dependency in
dfx.json
{
"canisters": {
"service": {
"type": "pull",
"id": "ig5e5-aqaaa-aaaan-qdxya-cai"
}
},
}
- Pull from mainnet
> dfx deps pull
Fetching dependencies of canister ig5e5-aqaaa-aaaan-qdxya-cai...
Found 1 dependencies:
ig5e5-aqaaa-aaaan-qdxya-cai
Pulling canister ig5e5-aqaaa-aaaan-qdxya-cai...
- Config the init argument
> dfx deps init
WARN: The following canister(s) require an init argument. Please run `dfx deps init <NAME/PRINCIPAL>` to set them individually:
ig5e5-aqaaa-aaaan-qdxya-cai (service)
> dfx deps init service
Error: Canister ig5e5-aqaaa-aaaan-qdxya-cai (service) requires an init argument. The following info might be helpful:
init => A natural number, e.g. 1
candid:args => (nat)
> dfx deps init service --argument 1
You can run the last command directly. The commands above shows how does a developer figure out the required init argument.
- Deploy on a local replica
> dfx start --clean --background
> dfx deps deploy
Creating canister: ig5e5-aqaaa-aaaan-qdxya-cai (service)
Installing canister: ig5e5-aqaaa-aaaan-qdxya-cai (service)
- Import the dependency and make inter-canister call (source code)
> dfx deploy app
> dfx canister call app double_service
(2 : nat)
This repository is also a reference for service providers.
Check PULLABLE.md for a step by step instruction.