Skip to content

Instantly share code, notes, and snippets.

@earthflower
Created April 12, 2022 09:57
Show Gist options
  • Save earthflower/ef13983221174a21e33c00affabb514c to your computer and use it in GitHub Desktop.
Save earthflower/ef13983221174a21e33c00affabb514c to your computer and use it in GitHub Desktop.
abhi_onboarding
https://smartcontracts.org/docs/quickstart/1-quickstart.html
https://www.google.com/search?gs_ssp=eJzj4tDP1TcwSiooNGD04kgpSkzPz1OoAgA8VAYb&q=dragon+z&rlz=1C5CHFA_enIN963IN964&oq=dragon+z&aqs=chrome.1.69i57j46i512j0i512j46i512j0i512l2j0i10i512j0i512l3.2933j0j7&sourceid=chrome&ie=UTF-8#wgvs=e&wptab=s:H4sIAAAAAAAAAONgVuLQz9U3MEoqKHzEaMwt8PLHPWEprUlrTl5jVOHiCs7IL3fNK8ksqRQS42KDsnikuLjgmnh2MbGFlDlnJBYtYpVIKUpMz89TSErMyVGoUkgGCiYml6QWFQMA8u9j-GYAAAA
https://discord.com/invite/UFjtDNJfeV
https://smartcontracts.org/docs/developers-guide/computation-and-storage-costs.html
https://github.com/earthgohan/examples.git
https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.ic0.app/
https://entrepot.app/marketplace
'rwlgt-iiaaa-aaaaa-aaaaa-cai': 'nns/registry',
'rrkah-fqaaa-aaaaa-aaaaq-cai': 'nns/governance',
'ryjl3-tyaaa-aaaaa-aaaba-cai': 'nns/ledger',
'r7inp-6aaaa-aaaaa-aaabq-cai': 'nns/root',
'rkp4c-7iaaa-aaaaa-aaaca-cai': 'nns/cycles-minting',
'rno2w-sqaaa-aaaaa-aaacq-cai': 'nns/lifeline',
'renrk-eyaaa-aaaaa-aaada-cai': 'nns/genesis-token',
'rdmx6-jaaaa-aaaaa-aaadq-cai': 'nns/identity',
'qoctq-giaaa-aaaaa-aaaea-cai': 'nns/nns-ui',
https://networknervoussystem.com/
https://medium.com/dfinity/the-dfinity-blockchain-nervous-system-a5dd1783288e
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
https://k7gat-daaaa-aaaae-qaahq-cai.ic0.app/listing/ic-management-10246/aaaaa-aa
https://docs.dank.ooo/xtc/canister-development/
dfx canister --network=ic call aanaa-xaaaa-aaaah-aaeiq-cai wallet_call "(record { canister= principal \"aaaaa-aa\"; method_name= \"install_code
\"; args= blob \"DIDL\01nh\01\00\00\"; cycles= (0:nat64); })"
@earthflower
Copy link
Author

let response = await canisterAgent({
canisterId: "cyiep-riaaa-aaaam-qadnq-cai",
method: "getTransactions",
args: [0,100],
});

@earthflower
Copy link
Author

earthflower commented Apr 13, 2022

import { canisterAgent } from '@earthwallet/assets';

let response = await canisterAgent({
canisterId: "cyiep-riaaa-aaaam-qadnq-cai",
method: "mint",
args: [Principal.fromText('xyz'),100],
});



const agent = await Promise.resolve(
    new HttpAgent({
      host: ICP_TESTNET_HOST,
      fetch,
      identity,
    })
  ).then(async (ag) => {
    await ag.fetchRootKey();
    return ag;
  });

  const API = Actor.createActor(TOKEN, {
    agent: agent,
    canisterId: tokenCanisterId,
  });


let response = API.mint([Principal.fromText('xyz'),100])

@earthflower
Copy link
Author

earthflower commented Apr 13, 2022

  1. Create canister for hello using dfx (precondition you should have minimum 4T Cycles) in dfx terminal
  2. Once you get your canister id, commit that to your fork of examples
  3. Go to local canidmanager or canlista and enter that canister id and verify your existing dfx terminal principal is listed in controllers
    dfx canister --network ic info NEWLY_GENERATED_ID

@earthflower
Copy link
Author

  1. Using dfx canister --network ic update-settings append earthwallet principal that is holding SDR balance thereby this principal will be co-owner of hello canister
  2. now using sdr contractor and using canisterAgent and wallet_call method try to using update_settings and append a new controller wopu3-2wttv-ac5mo-d5wr6-eoabn-qblqu-k3dhh-gthw6-6n4v7-wth3y-yqe

@earthflower
Copy link
Author

dfx canister --network=ic call cyiep-riaaa-aaaam-qadnq-cai wallet_call "(record { canister= principal \"NEWLY_GENERATED_ID\"; method_name= \"update_settings\"; args= blob \"????"; cycles= (0:nat64); })"

@earthflower
Copy link
Author


unameOut="$(uname -s)"
case "${unameOut}" in
    Linux*)     machine=Linux;;
    Darwin*)    machine=Mac;;
    *)          machine="UNKNOWN:${unameOut}"
esac

release=$(curl --silent "https://api.github.com/repos/dfinity/candid/releases/latest" | grep -e '"tag_name"' | cut -c 16-25)

if [ ${machine} = "Mac" ]
then
  echo "Downloading didc for Mac to /usr/local/bin/"
  curl -fsSL https://github.com/dfinity/candid/releases/download/${release}/didc-macos > /usr/local/bin/didc
  echo "Please run -> sudo chmod 0755 /usr/local/bin/didc"
elif [ ${machine} = "Linux" ]
then
  echo "Downloading didc for Linux to ~/bin/didc"
  curl -fsSL https://github.com/dfinity/candid/releases/download/${release}/didc-linux64 > ~/bin/didc
else
  echo "Could not detect a supported operating system. Please note that didc is currently only supported for Mac and Linux"
fi

date

@earthflower
Copy link
Author

@earthflower
Copy link
Author

dfx canister --network=ic call cyiep-riaaa-aaaam-qadnq-cai wallet_call "(record { canister= principal "aaaaa-aa"; method_name= "update_settings"; args= blob "????"; cycles= (0:nat64); })"

const args = { canisterId : Principal.fromText(NEWLY_GENERTAED_ID, settings: { controllers: [Principal.fromText(terminal), Principal.fromText(wallet), Principal.fromText(wopu3-2wttv-ac5mo-d5wr6-eoabn-qblqu-k3dhh-gthw6-6n4v7-wth3y-yqe) ]} }

@earthflower
Copy link
Author

https://github.com/Toniq-Labs/wrapped_cycles/blob/cb4d372b19bcee46472b12102f8ade8d0446efac/MINTING.md

wallet_call "(record { canister = principal "5ymop-yyaaa-aaaah-qaa4q-cai"; method_name = "mint"; args = $(didc encode '(opt variant { address = "'$TO_ADDRESS'" })' -f blob); cycles = ($CYCLES:nat64); } )"

@earthflower
Copy link
Author

record {canisterId = principal "$HELLOCAN"; settings =record {controllers = vec [principal "$HELLOCAN", principal "$HELLOCAN", principal "$HELLOCAN"]}}

@earthflower
Copy link
Author

args = record {canister_id:principal "$HELLOCAN"})

dfx canister --network=ic call cyiep-riaaa-aaaam-qadnq-cai wallet_call "(record { canister= principal "aaaaa-aa"; method_name= "canister_status"; args= blob "????"; cycles= (0:nat64); })"

@earthbardock
Copy link

earthbardock commented Apr 14, 2022

Get canister status via SDR wallet_call

dfx canister --network ic call cyiep-riaaa-aaaam-qadnq-cai wallet_call "(record { canister = principal \"aaaaa-aa\"; method_name = \"canister_status\"; args = $(didc encode '(record { "canister_id" = principal "bso2y-jqaaa-aaaai-qjbda-cai" })' -f blob); cycles = (0:nat64); } )"

Update controllers via SDR wallet_call
dfx canister --network ic call cyiep-riaaa-aaaam-qadnq-cai wallet_call "(record { canister = principal \"aaaaa-aa\"; method_name = \"update_settings\"; args = $(didc encode '(record { "canister_id" = principal "bso2y-jqaaa-aaaai-qjbda-cai"; "settings" = record { "controllers" = vec { principal "b4mxq-saaaa-aaaai-qjbca-cai";principal "cyiep-riaaa-aaaam-qadnq-cai";principal "rccv6-7j62g-j7sqe-y4hzo-mgkim-wyafm-7anwb-eqbyo-mpm2u-wsikn-xqe";principal "h3bad-mtrnv-6zzks-ih4zr-fkkiz-zuubu-g6kab-itcoq-nhvtn-tqkwd-pqe";principal "wopu3-2wttv-ac5mo-d5wr6-eoabn-qblqu-k3dhh-gthw6-6n4v7-wth3y-yqe";}; }; })' -f blob); cycles = (0:nat64); } )"

To decode blob output received
didc decode -f blob 'blob "DIDL\01k\01\ae\9d\b1\90\01h\01\00\00\01\0a\00\00\00\00\01\10HF\01\01"'

@earthflower
Copy link
Author

dfx canister --network ic --no-wallet call cyiep-riaaa-aaaam-qadnq-cai wallet_call "(record { canister = principal "aaaaa-aa"; method_name = "canister_status"; args = $(didc encode '(record { "canister_id" = principal "bso2y-jqaaa-aaaai-qjbda-cai" })' -f blob); cycles = (0:nat64); } )"

@earthflower
Copy link
Author

dfx identity --network=ic set-wallet cyiep-riaaa-aaaam-qadnq-cai --force

@earthbardock
Copy link

  1. wallet_call method SDR candid ui PR (candid_method) https://github.com/earthdao/SDR/blob/3bf0e7b4b8e1f9fbac78765cce0e6a30f70bf87f/sdr/src/cycles_wallet.rs#L34
  2. when canister is created via SDR wallet_create_canister add SDR principal as one of the controller PR

@earthflower
Copy link
Author

@earthflower
Copy link
Author

earthflower commented Apr 14, 2022

fork QueryIntegration and update createCanister with controllers as current principal and principal of SDR

controller: [Principal.fromText(),Principal.fromText(],

@earthflower
Copy link
Author

earthflower commented Apr 14, 2022

  1. install ic_kit and add candid_method macros to hello method

  2. deploy hello using dfx local wallet
    should see candid file here https://k7gat-daaaa-aaaae-qaahq-cai.ic0.app/canister/b3nre-7yaaa-aaaai-qjbcq-cai

  3. update hello contract and add version

#[query]
#[candid_method(query)]
fn version() -> &'static str {
    "0.0.1"
}

using wallet_call proxy install_code using terminal ( https://qrd.at/mX8 )

  1. again lets do update using javascript

@earthbardock
Copy link

  1. Add FileUploader component to candidmanager
  2. Add module hash to meta of the canister(canister component)
  3. Try out both Array.from Uint8Array to upload wasm from here

@earthflower
Copy link
Author

@earthflower
Copy link
Author

using web3 or ethers .. sending transaction(gasLimit is always 21000) for send tx

@earthflower
Copy link
Author

@earthbardock
Copy link

  1. send PR for ETH transfer assets
  2. manage (upload canister)
  3. canisters management (install code, update settings, start,stop,delete,canister status)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment