You need to:
0) Run chopsticks with the relay chain and the parachain you want
system::authorizeUpgrade(hash)
with the hash of the new wasm. You can hash the file in the PJS Apps UI if neededxcmPallet::send()
that sends the following message to the parachain you want to upgrade: [UnpaidExecution, Transact(Superuser, enough_weight, call)] with the previous callpreimage::note_preimage(previous call)
import { ApiPromise, WsProvider } from '@polkadot/api';
const api = await ApiPromise.create({
provider: new WsProvider(<your websocket endpoint>)
});
// get current block number.
const number = (await api.rpc.chain.getHeader()).number.toNumber();
// use chopsticks dev_setStorage to inject the call into the scheduler state for the next block.
await api.rpc('dev_setStorage', {
scheduler: {
agenda: [
[
[number + 1], [
{
call: {
Lookup: {
hash: <preimage hash from step 3>,
len: <preimage length from step 3 (not the hash length)>
}
},
origin: {
system: 'Root'
}
}
]
]
]
}
});
// Make a block to include the extrinsic
await api.rpc('dev_newBlock', { count: 1 });
system::authorizedUpgrade
has the hash you want. You can do that in PJS Apps -> Chain statesystem::applyAuthorizedUpgrade
with the wasm directly on the parachain