Closed forgetso closed 3 years ago
It probably has to do with the version of the chain you are using. Which chain are you using?
I'm using the substrate contracts node which is now the recommended one for testing contracts. I was previously using canvas node but it stopped working when I upgraded it.
https://github.com/paritytech/substrate-contracts-node
substrate-contracts-node 0.1.0-35eeb84-x86_64-linux-gnu
It appears this is a problem with yarn test
only. When I run a modified deploy.ts.
, I can instantiate the contract and also send a balance.
e.g. running the below code with npx redspot run ./scripts/deploy.ts --verbose --log-level 2
works. Running yarn test
does not work.
import {network, patract} from "redspot";
const {getContractFactory, getRandomSigner} = patract;
const {createSigner, keyring, api} = network;
async function run() {
await api.isReady;
// The redspot signer supports passing in an address. If you want to use substrate uri, you can do it like this:
// const signer = createSigner(keyring.createFromUri("bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice"));
// Or get the configured account from redspot config:
// const signer = (await getSigners())[0]
const signer = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"; // Alice Address
const contractFactory = await getContractFactory("erc20", signer);
const balance = await api.query.system.account(signer);
console.log("Balance: ", balance.toHuman());
// The `deploy` method will attempt to deploy a new contract.
// The `deployed` method will first find out if the same contract already exists based on the parameters.
// If the contract exists, it will be returned, otherwise a new contract will be created.
const contract = await contractFactory.deploy("new", "1000000", {
gasLimit: "400000000000",
value: "100000 UNIT",
});
console.log("");
console.log(
"Deploy successfully. The contract address: ",
contract.address.toString()
);
const receiver = await getRandomSigner();
await contract.tx.transfer(receiver.address, 7);
const receiverBalance = await contract.query.balanceOf(receiver.address);
console.log("Balance: ", receiverBalance.output?.toHuman());
api.disconnect();
}
run().catch((err) => {
console.log(err);
});
Ok, I can see that this is an issue with the test script:
const contract = await contractFactory.deploy("new", "1000");
Should be changed to:
const contract = await contractFactory.deploy("new", "1000", {
gasLimit: "400000000000",
value: "1000 UNIT",
});
I've re-opened as the initial this.api.consts.contracts.tombstoneDeposit
issue is still relevant.
It probably has to do with the version of the chain you are using. Which chain are you using?
I'm also having the same issue. Can you explain what this means? I'm using my local chain (current substrate master branch)
It probably has to do with the version of the chain you are using. Which chain are you using?
I'm also having the same issue. Can you explain what this means? I'm using my local chain (current substrate master branch)
ok we have test for substrate-contracts-node, because it was only recently proposed by parity, we haven’t adapted their changes yet.
we will update those related issue after we test.
maybe related to https://github.com/patractlabs/redspot/issues/141
we have found reason, it's related to the removed rent https://github.com/paritytech/substrate/pull/9669
we will fix it soon and release a new version
v0.12.2 is compatible with the new version of the chain.
Thanks guys
Redspot Version v0.11.9-3
Using basic deploy code (e.g. erc20 example) results in an error.
Changing
this.api.consts.contracts.tombstoneDeposit
tothis.api.consts.contracts.schedule.hostFnWeights.tombstoneDeposit
inpackages/redspot-patract/src/contractFactory.ts
causes this error to go away.The contract then appears to deploy ok using the deploy script. However, a new issue appears when running the
yarn test
:I've tried changing the initial contract funding up to 100,000 UNIT but still get the same error.