Skip to content

lwshang/pullable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pullable

Demo the "pull dependencies" workflow provided by dfx.

How to pull

The example project demonstrates how does an application canister pull its dependency from mainnet and integrate with it locally.

  1. Declare the pull dependency in dfx.json
{
  "canisters": {
    "service": {
      "type": "pull",
      "id": "ig5e5-aqaaa-aaaan-qdxya-cai"
    }
  },
}
  1. 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...
  1. 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.

  1. 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)
  1. Import the dependency and make inter-canister call (source code)
> dfx deploy app
> dfx canister call app double_service
(2 : nat)

How to make a canister pullable?

This repository is also a reference for service providers.

Check PULLABLE.md for a step by step instruction.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages