s.Takahashi
s.Takahashi

Reputation: 469

"contract" can be obtained as a result of "signAndSend", but the compilation error is not resolved

Sample Code:

const deployContract = async () => {
    const { web3FromSource } = await import("@polkadot/extension-dapp");
    const keyring = new Keyring({ type: 'sr25519' });
    const alicePair = keyring.addFromUri('//Alice', { name: 'Alice default' });
    const caller = keyring.addFromAddress("actingAddress");
    const wsProvider = new WsProvider(blockchainUrl);
    const api = await ApiPromise.create({ provider: wsProvider });
    setApi(api);
    const contractWasm = contract_file.source.wasm;
    const code = new CodePromise(api, abi, contractWasm);
    const initValue = false;
    console.log("contract is :", code);
    const performingAccount = accounts[0];
    const injector = await web3FromSource(performingAccount.meta.source);
    const tx = code.tx.new({ gasLimit, storageDepositLimit }, initValue)
    let address;
    const unsub = await tx.signAndSend(alicePair, ({ contract, status }) => {
      if (status.isInBlock || status.isFinalized) {
        address = contract.address.toString();
        unsub();
      }
    });
  };

Compile Error:

./pages/index.tsx:64:10
Type error: Property 'contract' does not exist on type 'ISubmittableResult'.

  62 |       actingAddress,
  63 |       { signer: injector.signer },
> 64 |       ({ contract, status }) => {
     |          ^
  65 |         if (status.isInBlock) {
  66 |           setResult("in a block");
  67 |         } else if (status.isFinalized) {

> Build error occurred

Thank you.

Upvotes: 1

Views: 93

Answers (0)

Related Questions