33 };
34
35 web3.eth.accounts
36 .signTransaction(tx, YOUR_PRIVATE_KEY)37 .then((signedTx) => web3.eth.sendSignedTransaction(signedTx.rawTransaction))
38 .on('transactionHash', (hash) => console.log(`Transaction hash: ${hash}`))
39 .on('confirmation', (confirmationNumber, receipt) => {
24 const txCount = await web3.eth.getTransactionCount(YOUR_ACCOUNT_ADDRESS);
25 const tx = {
26 from: YOUR_ACCOUNT_ADDRESS,
27 to: LendingContract.address,28 value: '0',
29 gas: '200000',
30 gasPrice: '20',
23 );
24 const txCount = await web3.eth.getTransactionCount(YOUR_ACCOUNT_ADDRESS);
25 const tx = {
26 from: YOUR_ACCOUNT_ADDRESS,27 to: LendingContract.address,
28 value: '0',
29 gas: '200000',
21 LendingContract.abi,
22 LendingContract.address,
23 );
24 const txCount = await web3.eth.getTransactionCount(YOUR_ACCOUNT_ADDRESS);25 const tx = {
26 from: YOUR_ACCOUNT_ADDRESS,
27 to: LendingContract.address,
19 );
20 const contract = new web3.eth.Contract(
21 LendingContract.abi,
22 LendingContract.address,23 );
24 const txCount = await web3.eth.getTransactionCount(YOUR_ACCOUNT_ADDRESS);
25 const tx = {
18 ),
19 );
20 const contract = new web3.eth.Contract(
21 LendingContract.abi,22 LendingContract.address,
23 );
24 const txCount = await web3.eth.getTransactionCount(YOUR_ACCOUNT_ADDRESS);
13
14 // Call the smart contract's repayLoan function
15 const web3 = new Web3(
16 new Web3.providers.HttpProvider(17 'https://mainnet.infura.io/v3/YOUR_PROJECT_ID',
18 ),
19 );
12 const repaymentAmount = document.getElementById('repayment-amount').value;
13
14 // Call the smart contract's repayLoan function
15 const web3 = new Web3(16 new Web3.providers.HttpProvider(
17 'https://mainnet.infura.io/v3/YOUR_PROJECT_ID',
18 ),
Variables that aren't defined, but accessed may throw reference errors at runtime.
NOTE: In browser applications, DeepSource recommends the use of ESModules over regular
text/javascript
scripts. Using variables that are injected by scripts included in an HTML file is currently not supported.
Potential ReferenceError
s may result from misspellings of variable and parameter names, or accidental implicit globals (for example, forgetting the var
keyword in a for
loop initializer).
Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /*global ...*/
comment, or specified in the globals key in the configuration file.
A common use case for these is if you intentionally use globals that are defined elsewhere (e.g. in a script sourced from HTML).
Bad Practice
const foo = someFunction(); // `someFunction` is not defined
const bar = baz + 1; // 'baz' is undeclared
Recommended
import { someFunction } from 'some-file';
const baz = Math.random();
const foo = someFunction();
const bar = baz + 1;