Skip to content

Commit 488d32e

Browse files
critesjoshclaude
andcommitted
fix: use node.getContract() for multi-PXE contract sharing in v4
In v4, instead of reconstructing contract instance from params, get it from the node directly using node.getContract(). This avoids triggering the forbidden sync_state during registration. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0f85d70 commit 488d32e

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

scripts/multiple_wallet.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,23 @@ async function main() {
106106
});
107107

108108

109-
// Note: In v4, registering a contract deployed by another PXE triggers sync_state
110-
// which is now forbidden. Multi-PXE contract sharing requires a different approach.
111-
console.log("Token minted successfully to wallet2 address:", wallet2Address.toString())
109+
// In v4, get the contract instance from the node instead of reconstructing locally
110+
const tokenInstance = await node.getContract(token.address);
111+
if (!tokenInstance) {
112+
throw new Error("Token contract not found on node");
113+
}
114+
await wallet2.registerContract(tokenInstance, TokenContract.artifact);
115+
116+
const l2TokenContract = await TokenContract.at(
117+
token.address,
118+
wallet2
119+
)
120+
121+
// Check balance
122+
const balance = await l2TokenContract.methods.balance_of_private(wallet2Address).simulate({
123+
from: wallet2Address
124+
})
125+
console.log("private balance should be 100", balance)
112126

113127
}
114128

0 commit comments

Comments
 (0)