Asset canister upload script

Does anyone know of a stand-alone way to upload an asset to an asset canister (such as a nice script that will call all of the asset canister batching and chunking functions automatically)? I’ve forked the asset canister and deployed it locally, and I’d love a simple way to upload files into it, but there’s no way that I know of to do that (so I’m writing my own script).

I’m hoping this work has already been done by somebody. Has it?

2 Likes

There is a CLI: agent-rs/icx-asset at main · dfinity/agent-rs · GitHub

5 Likes

Excellent! Thank you

1 Like

I want to add a npm package making this simple in JS, too

5 Likes

That would also be excellent

1 Like

That’s what I was going to do but I probably won’t now

1 Like

Can it be used locally? Do you know how that would be done? I passed it a local canister id and I get this error:

thread 'main' panicked at 'Could not create HTTP client.: reqwest::Error { kind: Builder, source: "Unknown TLS backend passed to `use_preconfigured_tls`" }', /home/lastmjs/.cargo/registry/src/github.com-1ecc6299db9ec823/ic-agent-0.10.0/src/agent/http_transport.rs:62:18
1 Like

If you’ve got the time and motivation to write it up, I’m happy to see if we could get you set up with a grant for it!

1 Like

I think I’m running into this issue: chore: update cargo dependencies by ericswanson-dfinity · Pull Request #285 · dfinity/agent-rs · GitHub

1 Like

Ah thanks for the offer, I should really get back to the TypeScript, Python CDKs and Sudograph. I’m taking a slight detour for this: https://twitter.com/dominic_w/status/1467144071449915395

Checks a lot of boxes for me, Demergence has issues with streaming, easy to pick up too

I got it to work by installing the main branch

I’ve been doing that with a little zsh script, but it sounds like you’re up and running!

2 Likes

Offer is still there? I would be interested to give it a go if I have some help

I’m happy to off guidance if you need it too, @lastmjs on Telegram is best

Thanks I could definitely use some help.
I have a rough idea on where to start by calling the asset canister actor methods, but I have few questions:

1-What is the order of calling these methods or the order of the process? create_batch, commit_batch etc…

2- how do you authorize the actor from within the script? ‘dfx deploy’ do that automatically but I am not sure how to do that manually

I found how to authorize with your private key in here

That was really helpful

mind sharing that @jorgenbuilder ?:slight_smile:

1 Like

For those running into the same issue (I got it from using ic-repl), just make sure to update the Cargo.toml of the binary you’re trying to build like this:

-ic-agent = "0.9.0"
+ic-agent = { git = "https://github.com/dfinity/agent-rs" }
2 Likes

I tested it and it works great for local development. Can this be used to upload assets to a canister deployed on mainnet too?

1 Like