@@ -8991,23 +8991,26 @@ r2
89918991// Reads the compiled bytecode for a given contract
89928992const getByteCode = (contractName) => {
89938993 try {
8994- return `0x${readFileSync(
8995- join(codegenDir, `${contractName}.polkavm`),
8996- ).toString('hex')}`;
8994+ const bytecodePath = join(
8995+ codegenDir,
8996+ '../contracts',
8997+ `${contractName}.polkavm`,
8998+ );
8999+ return `0x${readFileSync(bytecodePath).toString('hex')}`;
89979000 } catch (error) {
89989001 console.error(
89999002 `Could not find bytecode for contract ${contractName}:`,
90009003 error.message,
90019004 );
9002- throw error;
9003- }
9004- };
90059005 ```
90069006
900790074. Create the main deployment function:
90089008
90099009 ```js title="scripts/deploy.js"
9010- console.log(`Deploying ${contractName}...`);
9010+ };
9011+
9012+ const deployContract = async (contractName, mnemonic, providerConfig) => {
9013+ console.log(`Deploying ${contractName}...`);
90119014
90129015 try {
90139016 // Step 1: Set up provider and wallet
@@ -9039,22 +9042,18 @@ const getByteCode = (contractName) => {
90399042 addresses[contractName] = address;
90409043 writeFileSync(addressesFile, JSON.stringify(addresses, null, 2), 'utf8');
90419044 } catch (error) {
9042- console.error(`Failed to deploy contract ${contractName}:`, error);
9043- }
9044- };
90459045 ```
90469046
904790475. Configure and execute the deployment:
90489048
90499049 ```js title="scripts/deploy.js"
9050- rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io',
9050+ };
9051+
9052+ const providerConfig = {
9053+ rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io',
90519054 chainId: 420420422,
90529055 name: 'polkadot-hub-testnet',
90539056};
9054-
9055- const mnemonic = 'INSERT_MNEMONIC';
9056-
9057- deployContract('Storage', mnemonic, providerConfig);
90589057 ```
90599058
90609059 !!! note
@@ -9099,9 +9098,12 @@ const getAbi = (contractName) => {
90999098// Reads the compiled bytecode for a given contract
91009099const getByteCode = (contractName) => {
91019100 try {
9102- return `0x${readFileSync(
9103- join(codegenDir, `${contractName}.polkavm`),
9104- ).toString('hex')}`;
9101+ const bytecodePath = join(
9102+ codegenDir,
9103+ '../contracts',
9104+ `${contractName}.polkavm`,
9105+ );
9106+ return `0x${readFileSync(bytecodePath).toString('hex')}`;
91059107 } catch (error) {
91069108 console.error(
91079109 `Could not find bytecode for contract ${contractName}:`,
0 commit comments