-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
configuring @polkadot-js/api to use custom types w/ redspot #117
Comments
In fact, in your case, you should not use extendedEnvironment, you should use redspot.config. example: import types from "@plasm/types";
...
export default {
network: {
...
plasm: {
endpoint: "wss://....",
gasLimit: "400000000000",
accounts: [process.env.YOUR_ACCOUNT_SURI],
types: {
...types.dustyDefinitions,
},
},
....
}
} Then when you run the script you can specify the network: Now you can access the api object inside your code, which already contains the configured types: import { network, patract } from "redspot";
const { api } = network;
console.log(api.registry.knownTypes) This is the configuration document https://docs.patract.io/en/redspot/configuration.html#configuration-options We are in the process of optimizing the English documentation. But the translation may not be very good now. |
thanks! so do I set |
thanks! what is meant by Also I tried what you recommended. first I put kentarovadney@Kentaros-MacBook-Air erc20 % npx redspot run ./scripts/deploy.ts --no-compile /Users/kentarovadney/Desktop/code/tutorials/erc20/node_modules/@polkadot/api/base/Init.cjs:88 Then I tried with the --network plasm flag and it almost seemed to work:kentarovadney@Kentaros-MacBook-Air erc20 % npx redspot run ./scripts/deploy.ts --no-compile --network plasm ERROR 1010: Invalid Transaction: Inability to pay some fees , e.g. account balance too low 09:23:55 RedspotPluginError: Instantiation failed Why is it saying the instantiation failed? do I have to endow the smart contract with PLD to pay for gas like costs? Am I supposed to accounts: [] <- from redspot.config.ts? I copied the rest of the network definition as you sent here is the repo of the code I am writing. I'm trying to make a tutorial on how to deploy to plasm via redspot: |
First of all, global options does not support configuration using .env files. However, it may be possible to support it in the future. The reason it fails is because you need to have an account with a sufficient balance in it You need to understand this code. In this case suri is the private key of your account. You can find a detailed explanation of suri here (https://polkadot.js.org/docs/keyring/start/suri/). |
Ahh makes sense, my bad. Thanks! I got the code to deploy but it won't instantiate for some reason now. It doesn't seem to show the error message but it does say where the error is. I tried running with kentarovadney@Kentaros-MacBook-Air erc20 % npx redspot run ./scripts/deploy.ts --no-compile --network plasm ERROR { 16:04:51 RedspotPluginError: Instantiation failed I run the same command immediately after and I am told all of my funds are gone:kentarovadney@Kentaros-MacBook-Air erc20 % ERROR 1010: Invalid Transaction: Inability to pay some fees , e.g. account balance too low 16:11:45 RedspotPluginError: Instantiation failed |
Not sure where the issues are from so cross posted on polkadot-js repo: polkadot-js/apps#5487 |
I'm not quite sure what's going on with this one. Theoretically it's not possible, the account nonce was 5 before and then the account nonce changed to 0 when run again. |
It turned out my tokens were being burned, but I'm not sure why the nonce seems to have been reset... I dont have any control over the dusty chain but I am connecting to my local node that I turn on and off so maybe that is where the nonce is set? I am running into another issue. I can now deploy but I cannot instantiate for some reason. I have not modified the original code and is still viewable in the git repo link above: Sorry did not realize I put the wrong image here. Here was my error. The code deployed but did not instantiate. Also using the
|
@VadneyK I've added the plasm example and it should work. Steps to run the plasm example:
|
@VadneyK Then use this repository: https://github.com/ii-ii-ii/tutorials/tree/redspot-example/erc20 It should work. |
Awesome, thanks! I guess the instantiation is not needed for non-erc since once the contract is deployed it is enough so the deploy.ts was edited to reflect this right? |
I added the plasm network config in redspot.config.ts that you told me earlier. I also changed the account address to mine: kentarovadney@Kentaros-MacBook-Air plasm % npx redspot run ./scripts/deploy.ts --network dusty Error: Could not locate the bindings file. Tried: also npm i seemed to work but yarn still fails:kentarovadney@Kentaros-MacBook-Air plasm % npm i removed 485 packages, changed 8 packages, and audited 27 packages in 2s found 0 vulnerabilities ... snipped ... |
I'm running locally on this network: https://github.com/PlasmNetwork/Plasm/releases/tag/v1.9.0-dusty |
Hmm I just cloned your repo and did the same, but I can only connect my dusty account with |
You don't use your own account and follow my steps. Can you deploy it successfully? |
Yeah I used the |
If you don't use your own address, but use local network and the default test address, does it work correctly? We need to confirm if it is a problem with your address and the network you are using. |
I tried re-starting from the new erc20 starter you uploaded and copied over the configuration for dusty network in this branch. I did
but I get this error. Does this mean the deployed contract doesn't have enough endowment? how do I increase endowment? kentarovadney@Kentaros-MacBook-Air erc20 % npx redspot run ./scripts/deploy.ts --network dusty ERROR contracts.NewContractNotFunded( The newly created contract is below the subsistence threshold after executing its contructor. No contracts are allowed to exist below that threshold.) RedspotPluginError: Instantiation failed Also having no --network flag doesn't work either:kentarovadney@Kentaros-MacBook-Air erc20 % npx redspot run ./scripts/deploy.ts /Users/kentarovadney/Desktop/code/erc20/node_modules/@polkadot/api/base/Init.cjs:88 |
I tried to stay in the original file and on this branch and must use the alice account and did this:
but I got this error so I tried out the branch above: kentarovadney@Kentaros-MacBook-Air erc20 % npx redspot run ./scripts/deploy.ts --network dusty ===== Compile erc20 ===== [1/5] Building cargo project Original wasm size: 54.2K, Optimized: 32.7K Your contract artifacts are ready. You can find them in:
🎉 Compile successfully! You can find all artifacts at /Users/kentarovadney/Desktop/code/tutorials/erc20/artifacts |
The second error is because your dependency has not been upgraded. https://github.com/PlasmNetwork/tutorials/blob/redspot-alice/erc20/package.json It is best to copy my code in its entirety. https://github.com/ii-ii-ii/tutorials/blob/redspot-example/erc20/package.json |
this seemed to work from the terminal: However when I try to look it up in the dusty network to interact with it, it does not work. Don't I need to deploy this on the non-dev version of the dusty node to be able to interact with it online since I am in the dev node? how do I interact with a smart contract on a dev node (i.e. call the function s on the smart contract) is it just deployed within the local dev node so anything that connects to the local dev node can call it? |
merged changes here I tried entering my account's suri to the accounts:[HERE!!!] but I get the error below saying I can't pay the fee. why is this happening? I have 200PLD which should be enough. |
Hello I'm trying to deploy to dusty, the plasm test net via redspot by following the tutorial here.
In order to do this I need to use a custom type for the api object.
I saw in the docs that the
extendedEnvirionment()
can help with this.does this properly set the
api
imported fromnetwork
to have thetypes
field set as in@polkadot-js/api
? is thenetwork
api instance treated the same as the modified api in theextendedEnvironment()
call?Here is my attempt at editing
deploy.ts
to recognize the smartcontract via adding the custom plasm/types. all other files are not changed :I also saw that there are type definitions in
redspot.config.ts
but since I am using a custom type that requires an import, I cant configure the types there, correct?The text was updated successfully, but these errors were encountered: