Skip to content

Agent009/bc-ic-dbank

Repository files navigation

dbank

Very simple bank interface which allows users to deposit and withdraw funds. The funds accrue interest over time, but the compound is only calculated when the funds are deposited / withdrawn. The compounding function is a very silly one - 1% every minute. ...sigh... Only if...

Running the project locally

If you want to test your project locally, you can use the following commands:

# Starts the replica, running in the background
dfx start --clean --background

# Deploys your canisters to the replica and generates your candid interface
dfx deploy

Once the job completes, your application will be available at http://{asset_canister_id}.localhost:4943.

If you have made changes to your backend canister, you can generate a new candid interface with

npm run prebuild

at any time. This is recommended before starting the frontend development server, and will be run automatically any time you run dfx deploy.

If you are making frontend changes, you can start a development server with

npm start

Which will start a server at http://localhost:8080, proxying API requests to the replica at port 4943.

Note on frontend environment variables

If you are hosting frontend code somewhere without using DFX, you may need to make one of the following adjustments to ensure your project does not fetch the root key in production:

  • setDFX_NETWORK to ic if you are using Webpack
  • use your own preferred method to replace process.env.DFX_NETWORK in the autogenerated declarations
    • Setting canisters -> {asset_canister_id} -> declarations -> env_override to a string in dfx.json will replace process.env.DFX_NETWORK with the string in the autogenerated declarations
  • Write your own createActor constructor

Resolving CSP Issues

  • Add http://127.0.0.1:* in src/dbank_frontend/public/.ic-assets.json5
"Content-Security-Policy": "default-src 'self';script-src 'self';connect-src 'self' http://127.0.0.1:* http://localhost:* https://icp0.io https://*.icp0.io https://icp-api.io;img-src 'self' data:;style-src * 'unsafe-inline';style-src-elem * 'unsafe-inline';font-src *;object-src 'none';base-uri 'self';frame-ancestors 'none';form-action 'self';upgrade-insecure-requests;"

Resolving 403 Issues

In the local environment, this is usually due to using the network Internet Identity provider instead of using the local instance.

In the front-end canister, change the auth-client identityProvider over to: ${ii_canister_id}.localhost:4943#authorize

Also:

  • Use URLs of the format http://{asset_canister_id}.localhost:4943 instead of http://localhost:4943/?canisterId={asset_canister_id}
  • For candid, you would use the following URL: http://{candid_canister_id}.localhost:4943/?id={target_canister_id}

Resources

dfx build dbank_frontend
dfx canister install dbank_frontend --mode='reinstall'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published