Hi, eveyrone.
Currently, I have a exist wasm hash: 7e907b4367286769a6f0b1b13c0998dce0d678c2582c184210061f254b59956b
Via the command line I can deploy successfully:
$stellar contract deploy \
--wasm-hash 7e907b4367286769a6f0b1b13c0998dce0d678c2582c184210061f254b59956b \
--source alice \
--network testnet \
> -- --admin GBJIR3NUDYCX2TNHBTGPWIEUT5DNGBEUZHYCNY2GNECZRBST3M2II73U
✅ Deployed!
CCYJRY2UGDSNKYS3INOIYTKWNWH2Z53E76UUJAZZOHAAI2ZNNLA5KFFB
However, when I deployed it via the JS SDK, I encountered the following error:
/xxx/node_modules/@stellar/js-xdr/lib/webpack:/XDR/src/union.js:26
throw new TypeError(`${armName} not set`);
^
TypeError: bytes not set
at ChildUnion.get (/xxx/node_modules/@stellar/js-xdr/lib/webpack:/XDR/src/union.js:26:13)
at ChildUnion.get [as bytes] (/xxx/node_modules/@stellar/js-xdr/lib/webpack:/XDR/src/union.js:163:25)
This is part of my code:
// Build Operation
const operation = Operation.createCustomContract({
wasmHash: Buffer.from(
'7e907b4367286769a6f0b1b13c0998dce0d678c2582c184210061f254b59956b',
'hex',
);
address: Address.fromString(xxx),
salt,
constructorArgs: [xdr.ScVal.scvAddress(scAddress)],
});
const transaction = new TransactionBuilder(account, {
fee: BASE_FEE,
networkPassphrase: Networks.TESTNET,
})
.addOperation(operation)
.setTimeout(30)
.build();
const tx = await rpcServer.prepareTransaction(
transaction,
);
tx.sign(sourceKeypair);
const response = await horizonServer.submitTransaction(tx);
How to solve this problem?