区块链交易

news2025/3/26 0:38:31

文章目录

    • 交易
    • 准备
    • 合约和代码逻辑
      • 合约
      • compile.js
      • index.js
    • 运行

交易

项目来自https://github.com/Dapp-Learning-DAO/Dapp-Learning/blob/main/basic/02-web3js-transaction/README-cn.md

本项目包含对交易进行签名,发送,接收交易回执,验证交易执行结果。也提供了事件监听的逻辑代码。

准备

需要安装web3.js

其他和上一个项目环境一样,需要准备私钥和项目id。参考 上一篇。

合约和代码逻辑

合约

pragma solidity ^0.8.0;

contract Incrementer {
    uint256 public number;

    event Increment(uint256 value);
    event Reset();

    constructor(uint256 _initialNumber) {
        number = _initialNumber;
    }

    function increment(uint256 _value) public {
        require(_value > 0, "increment value should be positive number");
        number = number + _value;
        emit Increment(_value);
    }

    function reset() public {
        number = 0;
        emit Reset();
    }

    function getNumber() public view returns (uint256) {
        return number;
    }
}

compile.js

const fs = require('fs');
const solc = require('solc');

// 以 utf8 方式加载合约
const source = fs.readFileSync('Incrementer.sol', 'utf8');

// 编译合约
const input = {
  language: 'Solidity',
  sources: {
    'Incrementer.sol': {
      content: source,
    },
  },
  settings: {
    outputSelection: {
      '*': {
        '*': ['*'],
      },
    },
  },
};

const tempFile = JSON.parse(solc.compile(JSON.stringify(input)));
const contractOfIncrementer =
  tempFile.contracts['Incrementer.sol']['Incrementer'];

// 导出合约数据,可以使用 console 打印 contractFile 中的具体内容信息
module.exports = contractOfIncrementer;

index.js

const Web3 = require('web3');
const fs = require('fs');
const contractOfIncrementer = require('./compile');

require('dotenv').config();
const privatekey = process.env.PRIVATE_KEY;

function sleep(ms) {
  return new Promise((resolve) => setTimeout(resolve, ms));
}

/*
   -- Define Provider --
*/
// Provider
const providerRPC = {
  development: 'https://sepolia.infura.io/v3/' + process.env.INFURA_ID,
  moonbase: 'https://rpc.testnet.moonbeam.network',
};
const web3 = new Web3(providerRPC.development); //Change to correct network

// Create account with privatekey
const account = web3.eth.accounts.privateKeyToAccount(privatekey);
const account_from = {
  privateKey: privatekey,
  accountAddress: account.address,
};

// Get abi & bin
const bytecode = contractOfIncrementer.evm.bytecode.object;
const abi = contractOfIncrementer.abi;

/*
*
*
*   -- Verify Deployment --
*

*/
const Trans = async () => {
  console.log('============================ 1. Deploy Contract');
  console.log(`Attempting to deploy from account ${account.address}`);

  // Create Contract Instance
  const deployContract = new web3.eth.Contract(abi);

  // Create Deployment Tx
  const deployTx = deployContract.deploy({
    data: bytecode,
    arguments: [5],
  });
  
  // Sign Tx
  const createTransaction = await web3.eth.accounts.signTransaction(
    {
      data: deployTx.encodeABI(),
      gas: 8000000,
    },
    account_from.privateKey
  );

  // Get Transaction Receipt
  const createReceipt = await web3.eth.sendSignedTransaction(
    createTransaction.rawTransaction
  );
  console.log(`Contract deployed at address: ${createReceipt.contractAddress}`);

  const deployedBlockNumber = createReceipt.blockNumber;

  /*
   *
   *
   *
   * -- Verify Interface of Increment --
   *
   *
   */
  // Create the contract with contract address
  console.log();
  console.log(
    '============================ 2. Call Contract Interface getNumber'
  );
  let incrementer = new web3.eth.Contract(abi, createReceipt.contractAddress);

  console.log(
    `Making a call to contract at address: ${createReceipt.contractAddress}`
  );

  let number = await incrementer.methods.getNumber().call();
  console.log(`The current number stored is: ${number}`);

  // Add 3 to Contract Public Variable
  console.log();
  console.log(
    '============================ 3. Call Contract Interface increment'
  );
  const _value = 3;
  let incrementTx = incrementer.methods.increment(_value);

  // Sign with Pk
  let incrementTransaction = await web3.eth.accounts.signTransaction(
    {
      to: createReceipt.contractAddress,
      data: incrementTx.encodeABI(),
      gas: 8000000,
    },
    account_from.privateKey
  );

  // Send Transactoin and Get TransactionHash
  const incrementReceipt = await web3.eth.sendSignedTransaction(
    incrementTransaction.rawTransaction
  );
  console.log(`Tx successful with hash: ${incrementReceipt.transactionHash}`);

  number = await incrementer.methods.getNumber().call();
  console.log(`After increment, the current number stored is: ${number}`);

  /*
   *
   *
   *
   * -- Verify Interface of Reset --
   *
   *
   */
  console.log();
  console.log('============================ 4. Call Contract Interface reset');
  const resetTx = incrementer.methods.reset();

  const resetTransaction = await web3.eth.accounts.signTransaction(
    {
      to: createReceipt.contractAddress,
      data: resetTx.encodeABI(),
      gas: 8000000,
    },
    account_from.privateKey
  );

  const resetcReceipt = await web3.eth.sendSignedTransaction(
    resetTransaction.rawTransaction
  );
  console.log(`Tx successful with hash: ${resetcReceipt.transactionHash}`);
  number = await incrementer.methods.getNumber().call();
  console.log(`After reset, the current number stored is: ${number}`);

  /*
   *
   *
   *
   * -- Listen to Event Increment --
   *
   *
   */
  console.log();
  console.log('============================ 5. Listen to Events');
  console.log(' Listen to Increment Event only once && continuouslly');

  // sepolia don't support http protocol to event listen, need to use websocket
  // more details , please refer to  https://medium.com/blockcentric/listening-for-smart-contract-events-on-public-blockchains-fdb5a8ac8b9a
  const web3Socket = new Web3(
      'wss://sepolia.infura.io/ws/v3/' + process.env.INFURA_ID
  );

  // listen to  Increment event only once
  incrementer.once('Increment', (error, event) => {
    console.log('I am a onetime event listner, I am going to die now');
  });

  // listen to Increment event continuously
  web3Socket.eth.subscribe('logs',{
    address: createReceipt.contractAddress,
    topics: []
  },(error,result) => {
    if(error){
      console.error(error)
    }
  }
  ).on("data", (event) => {
      console.log("New event: ", event);
    })
    .on("error", (error) => {
      console.error("Error: ", error);
    });

  for (let step = 0; step < 3; step++) {
    incrementTransaction = await web3.eth.accounts.signTransaction(
      {
        to: createReceipt.contractAddress,
        data: incrementTx.encodeABI(),
        gas: 8000000,
      },
      account_from.privateKey
    );

    await web3.eth.sendSignedTransaction(incrementTransaction.rawTransaction);

    console.log("Waiting for events")
    await sleep(3000);
    
    if (step == 2) {
      // clear all the listeners
      web3Socket.eth.clearSubscriptions();
      console.log('Clearing all the events listeners !!!!');
    }
  }

  /*
   *
   *
   *
   * -- Get past events --
   *
   *
   */
  console.log();
  console.log('============================ 6. Going to get past events');
  const pastEvents = await incrementer.getPastEvents('Increment', {
    fromBlock: deployedBlockNumber,
    toBlock: 'latest',
  });

  pastEvents.map((event) => {
    console.log(event);
  });

  /*
   *
   *
   *
   * -- Check Transaction Error --
   *
   *
   */
  console.log();
  console.log('============================ 7. Check the transaction error');
  incrementTx = incrementer.methods.increment(0);
  incrementTransaction = await web3.eth.accounts.signTransaction(
    {
      to: createReceipt.contractAddress,
      data: incrementTx.encodeABI(),
      gas: 8000000,
    },
    account_from.privateKey
  );

  await web3.eth
    .sendSignedTransaction(incrementTransaction.rawTransaction)
    .on('error', console.error);
};

Trans()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

运行

============================ 1. Deploy Contract
Attempting to deploy from account 0x953bAac08Cad29A4E354F0833c404Ed528775B68
Contract deployed at address: 0xadD95f6bD6A0Fbd1423Bde9272dB999946A09369

============================ 2. Call Contract Interface getNumber
Making a call to contract at address: 0xadD95f6bD6A0Fbd1423Bde9272dB999946A09369
The current number stored is: 5

============================ 3. Call Contract Interface increment
Tx successful with hash: 0xf9121315472943c6c316c600072798813317563ee3994cfc2334ba20a453a4a1
After increment, the current number stored is: 8

============================ 4. Call Contract Interface reset
Tx successful with hash: 0xda76d0a839a40acfb654a37b7afe133c44cd81873f91d51ddfcff2b6052c2e0b
After reset, the current number stored is: 0

============================ 5. Listen to Events
 Listen to Increment Event only once && continuouslly
I am a onetime event listner, I am going to die now
New event:  {
  address: '0xadD95f6bD6A0Fbd1423Bde9272dB999946A09369',
  blockHash: '0x9e8d04cff3f2236eed7bf662036657963cf7475b0e350f77a396e89a4935de2c',
  blockNumber: 7947790,
  data: '0x0000000000000000000000000000000000000000000000000000000000000003',
  logIndex: 353,
  removed: false,
  topics: [
    '0x51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a81'
  ],
  transactionHash: '0xdc7dfda876800b365e70374b8f8f9f39d8603bebe89f961109f65229b93524d6',
  transactionIndex: 189,
  id: 'log_7432a4a4'
}
Waiting for events
New event:  {
  address: '0xadD95f6bD6A0Fbd1423Bde9272dB999946A09369',
  blockHash: '0x9ec619f890cdd8e0ab6a3e0bae4846351f81f6b81125fddd444c8e7a2598d970',
  blockNumber: 7947792,
  data: '0x0000000000000000000000000000000000000000000000000000000000000003',
  logIndex: 343,
  removed: false,
  topics: [
    '0x51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a81'
  ],
  transactionHash: '0x4956140582e6e0d62885e0646ad0642b6ae060fd4658d0374cd555799fa3a843',
  transactionIndex: 181,
  id: 'log_a193869e'
}
Waiting for events
New event:  {
  address: '0xadD95f6bD6A0Fbd1423Bde9272dB999946A09369',
  blockHash: '0xd8967836b9d85763611be4489042896b149b45b82f3404d530ad60a2cb8ca378',
  blockNumber: 7947793,
  blockTimestamp: '0x67dd0eb8',
  data: '0x0000000000000000000000000000000000000000000000000000000000000003',
  logIndex: 248,
  removed: false,
  topics: [
    '0x51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a81'
  ],
  transactionHash: '0x35163a22db0cffeeab3e2c4f6ca6f6a3f5e622982514ea98a6f99b3abc0e5d74',
  transactionIndex: 169,
  id: 'log_97159c2a'
}
Waiting for events
Clearing all the events listeners !!!!

============================ 6. Going to get past events
{
  removed: false,
  logIndex: 413,
  transactionIndex: 214,
  transactionHash: '0xf9121315472943c6c316c600072798813317563ee3994cfc2334ba20a453a4a1',
  blockHash: '0xdc82eb994a9884606ad817309a509f923aa4c9eb1444e1fdf0531f29919d67ca',
  blockNumber: 7947788,
  address: '0xadD95f6bD6A0Fbd1423Bde9272dB999946A09369',
  id: 'log_95b8ba97',
  returnValues: Result { '0': '3', value: '3' },
  event: 'Increment',
  signature: '0x51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a81',
  raw: {
    data: '0x0000000000000000000000000000000000000000000000000000000000000003',
    topics: [
      '0x51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a81'
    ]
  }
}
{
  removed: false,
  logIndex: 353,
  transactionIndex: 189,
  transactionHash: '0xdc7dfda876800b365e70374b8f8f9f39d8603bebe89f961109f65229b93524d6',
  blockHash: '0x9e8d04cff3f2236eed7bf662036657963cf7475b0e350f77a396e89a4935de2c',
  blockNumber: 7947790,
  address: '0xadD95f6bD6A0Fbd1423Bde9272dB999946A09369',
  id: 'log_7432a4a4',
  returnValues: Result { '0': '3', value: '3' },
  event: 'Increment',
  signature: '0x51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a81',
  raw: {
    data: '0x0000000000000000000000000000000000000000000000000000000000000003',
    topics: [
      '0x51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a81'
    ]
  }
}
{
  removed: false,
  logIndex: 343,
  transactionIndex: 181,
  transactionHash: '0x4956140582e6e0d62885e0646ad0642b6ae060fd4658d0374cd555799fa3a843',
  blockHash: '0x9ec619f890cdd8e0ab6a3e0bae4846351f81f6b81125fddd444c8e7a2598d970',
  blockNumber: 7947792,
  address: '0xadD95f6bD6A0Fbd1423Bde9272dB999946A09369',
  id: 'log_a193869e',
  returnValues: Result { '0': '3', value: '3' },
  event: 'Increment',
  signature: '0x51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a81',
  raw: {
    data: '0x0000000000000000000000000000000000000000000000000000000000000003',
    topics: [
      '0x51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a81'
    ]
  }
}
{
  removed: false,
  logIndex: 248,
  transactionIndex: 169,
  transactionHash: '0x35163a22db0cffeeab3e2c4f6ca6f6a3f5e622982514ea98a6f99b3abc0e5d74',
  blockHash: '0xd8967836b9d85763611be4489042896b149b45b82f3404d530ad60a2cb8ca378',
  blockNumber: 7947793,
  address: '0xadD95f6bD6A0Fbd1423Bde9272dB999946A09369',
  id: 'log_97159c2a',
  returnValues: Result { '0': '3', value: '3' },
  event: 'Increment',
  signature: '0x51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a81',
  raw: {
    data: '0x0000000000000000000000000000000000000000000000000000000000000003',
    topics: [
      '0x51af157c2eee40f68107a47a49c32fbbeb0a3c9e5cd37aa56e88e6be92368a81'
    ]
  }
}

============================ 7. Check the transaction error
Error: Transaction has been reverted by the EVM:
{
  "blockHash": "0x676c1930d40386e4011ae277099d0b0113fc9cddaff445c1ea529445f1a15d5f",
  "blockNumber": 7947794,
  "contractAddress": null,
  "cumulativeGasUsed": 20244362,
  "effectiveGasPrice": 7643386,
  "from": "0x953baac08cad29a4e354f0833c404ed528775b68",
  "gasUsed": 21875,
  "logs": [],
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "status": false,
  "to": "0xadd95f6bd6a0fbd1423bde9272db999946a09369",
  "transactionHash": "0x655d2b7ce84608cec8bbc09b6092bf1aa1cf9199496152e953517e51775be7ca",
  "transactionIndex": 143,
  "type": "0x0"
}
    at Object.TransactionError (C:\Users\26643\Downloads\Dapp-Learning-main\Dapp-Learning-main\basic\02-web3js-transaction\node_modules\web3-core-helpers\lib\errors.js:90:21)  
    at Object.TransactionRevertedWithoutReasonError (C:\Users\26643\Downloads\Dapp-Learning-main\Dapp-Learning-main\basic\02-web3js-transaction\node_modules\web3-core-helpers\lib\errors.js:101:21)
    at C:\Users\26643\Downloads\Dapp-Learning-main\Dapp-Learning-main\basic\02-web3js-transaction\node_modules\web3-core-method\lib\index.js:396:57
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  receipt: {
    blockHash: '0x676c1930d40386e4011ae277099d0b0113fc9cddaff445c1ea529445f1a15d5f',
    blockNumber: 7947794,
    contractAddress: null,
    cumulativeGasUsed: 20244362,
    effectiveGasPrice: 7643386,
============================ 7. Check the transaction error
Error: Transaction has been reverted by the EVM:
{
  "blockHash": "0x676c1930d40386e4011ae277099d0b0113fc9cddaff445c1ea529445f1a15d5f",
  "blockNumber": 7947794,
  "contractAddress": null,
  "cumulativeGasUsed": 20244362,
  "effectiveGasPrice": 7643386,
  "from": "0x953baac08cad29a4e354f0833c404ed528775b68",
  "gasUsed": 21875,
  "logs": [],
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "status": false,
  "to": "0xadd95f6bd6a0fbd1423bde9272db999946a09369",
  "transactionHash": "0x655d2b7ce84608cec8bbc09b6092bf1aa1cf9199496152e953517e51775be7ca",
  "transactionIndex": 143,
  "type": "0x0"
}
    at Object.TransactionError (C:\Users\26643\Downloads\Dapp-Learning-main\Dapp-Learning-main\basic\02-web3js-transaction\node_modules\web3-core-helpers\lib\errors.js:90:21)  
    at Object.TransactionRevertedWithoutReasonError (C:\Users\26643\Downloads\Dapp-Learning-main\Dapp-Learning-main\basic\02-web3js-transaction\node_modules\web3-core-helpers\lib\errors.js:101:21)
    at C:\Users\26643\Downloads\Dapp-Learning-main\Dapp-Learning-main\basic\02-web3js-transaction\node_modules\web3-core-method\lib\index.js:396:57
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  receipt: {
    blockHash: '0x676c1930d40386e4011ae277099d0b0113fc9cddaff445c1ea529445f1a15d5f',
    blockNumber: 7947794,
    contractAddress: null,
    cumulativeGasUsed: 20244362,
    effectiveGasPrice: 7643386,
  "from": "0x953baac08cad29a4e354f0833c404ed528775b68",
  "gasUsed": 21875,
  "logs": [],
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "status": false,
  "to": "0xadd95f6bd6a0fbd1423bde9272db999946a09369",
  "transactionHash": "0x655d2b7ce84608cec8bbc09b6092bf1aa1cf9199496152e953517e51775be7ca",
  "transactionIndex": 143,
  "type": "0x0"
}
    at Object.TransactionError (C:\Users\26643\Downloads\Dapp-Learning-main\Dapp-Learning-main\basic\02-web3js-transaction\node_modules\web3-core-helpers\lib\errors.js:90:21)  
    at Object.TransactionRevertedWithoutReasonError (C:\Users\26643\Downloads\Dapp-Learning-main\Dapp-Learning-main\basic\02-web3js-transaction\node_modules\web3-core-helpers\lib\errors.js:101:21)
    at C:\Users\26643\Downloads\Dapp-Learning-main\Dapp-Learning-main\basic\02-web3js-transaction\node_modules\web3-core-method\lib\index.js:396:57
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  receipt: {
    blockHash: '0x676c1930d40386e4011ae277099d0b0113fc9cddaff445c1ea529445f1a15d5f',
    blockNumber: 7947794,
    contractAddress: null,
    cumulativeGasUsed: 20244362,
    effectiveGasPrice: 7643386,
  "type": "0x0"
}
    at Object.TransactionError (C:\Users\26643\Downloads\Dapp-Learning-main\Dapp-Learning-main\basic\02-web3js-transaction\node_modules\web3-core-helpers\lib\errors.js:90:21)  
    at Object.TransactionRevertedWithoutReasonError (C:\Users\26643\Downloads\Dapp-Learning-main\Dapp-Learning-main\basic\02-web3js-transaction\node_modules\web3-core-helpers\lib\errors.js:101:21)
    at C:\Users\26643\Downloads\Dapp-Learning-main\Dapp-Learning-main\basic\02-web3js-transaction\node_modules\web3-core-method\lib\index.js:396:57
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  receipt: {
    blockHash: '0x676c1930d40386e4011ae277099d0b0113fc9cddaff445c1ea529445f1a15d5f',
    blockNumber: 7947794,
    contractAddress: null,
    cumulativeGasUsed: 20244362,
    effectiveGasPrice: 7643386,
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  receipt: {
    blockHash: '0x676c1930d40386e4011ae277099d0b0113fc9cddaff445c1ea529445f1a15d5f',
    blockNumber: 7947794,
    contractAddress: null,
    cumulativeGasUsed: 20244362,
    effectiveGasPrice: 7643386,
    blockNumber: 7947794,
    contractAddress: null,
    cumulativeGasUsed: 20244362,
    effectiveGasPrice: 7643386,
    cumulativeGasUsed: 20244362,
    effectiveGasPrice: 7643386,
    effectiveGasPrice: 7643386,
    from: '0x953baac08cad29a4e354f0833c404ed528775b68',
    gasUsed: 21875,
    logs: [],
    logs: [],
    logsBloom: '0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000    logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
00',
    status: false,
    status: false,
    to: '0xadd95f6bd6a0fbd1423bde9272db999946a09369',
    transactionHash: '0x655d2b7ce84608cec8bbc09b6092bf1aa1cf9199496152e953517e51775be7ca',
    transactionIndex: 143,
    type: '0x0'
  }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2321631.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Walrus 经济模型 101

本文作者&#xff1a;Steve_4P&#xff0c;文章仅代表作者观点。 要点总结 2025 年 3 月 20 日&#xff0c;Walrus 基金会宣布成功融资 约 1.4 亿美元&#xff0c;投资方包括 Standard Crypto、a16z 等机构。Walrus 当前估值约 20 亿美元&#xff0c;其中 7% 代币供应量分配给…

SpringCould微服务架构之Docker(1)

项目中微服务比较多的时候&#xff0c;一个一个手动的部署太麻烦了&#xff0c;所以就需要用到Docker。 项目部署中的问题&#xff1a; Docker是一种快速交付应用、运行应用的技术。

mac丝滑安装Windows操作系统【丝滑简单免费】

mac丝滑安装Windows操作系统【丝滑&简单&免费】 记录mac丝滑安装windows系统1、安装免费版 VMware fusion 132、安装Windows镜像文件3、跳过联网安装&#xff08;完成1后将2拖入1 点点点 即可来到3的环节&#xff09;4、 安装vmware 工具【非常重要&#xff0c;涉及联网…

系统与网络安全------网络应用基础(2)

资料整理于网络资料、书本资料、AI&#xff0c;仅供个人学习参考。 交换机 认识交换机 交换机&#xff0c;Switch 用户将多台计算机/交换机连接在一起&#xff0c;组建网络 交换机负责为其中任意两台计算机提供独享线路进行通信 非网管型交换机 即插即用交换机 即插即用&…

eclipse [jvm memory monitor] SHOW_MEMORY_MONITOR=true

eclipse虚拟机内存监控设置SHOW_MEMORY_MONITORtrue D:\eclipse-jee-oxygen-2-win32-x86_64\workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings org.eclipse.ui.prefs (文件比较多&#xff0c;别找错了&#xff09; SHOW_MEMORY_MONITORtrue 重启 -xms 1024…

【论文笔记】生成对抗网络 GAN

GAN 2014 年&#xff0c;Ian Goodfellow 等人提出生成对抗网络&#xff08;Generative Adversarial Networks&#xff09;&#xff0c;GAN 的出现是划时代的&#xff0c;虽然目前主流的图像/视频生成模型是扩散模型&#xff08;Diffusion Models&#xff09;的天下&#xff0c…

【Agent】Dify Docker 安装问题 INTERNAL SERVER ERROR

总结&#xff1a;建议大家选择稳定版本的分支&#xff0c;直接拉取 master 分支&#xff0c;可能出现一下后面更新代码导致缺失一些环境内容。 启动报错 一直停留在 INSTALL 界面 我是通过 Docker 进行安装的&#xff0c;由于项目开发者不严谨导致&#xff0c;遇到一个奇怪的…

【Excel使用技巧】某列保留固定字段或内容

目录 ✅ 方法一&#xff1a;使用 Excel 公式提取 body 部分 &#x1f50d; 解释&#xff1a; ✅ 方法二&#xff1a;批量处理整列数据 &#x1f6a8; 注意事项 &#x1f6a8; 处理效果 我想保留Excel某一列的固定内容&#xff0c;比如原内容是&#xff1a; thread entry i…

vue3,element-plus 表格搜索过滤数据

1、表格数据 // 表格数据 import type { User } from "/interface"; const tableData ref<User[]>([]); 2、 表格搜索过滤数据 // 搜索内容 const search ref(""); // 表格过滤数据 const tableFilterData computed(() >tableData.value.fi…

vue中上传接口file表单提交二进制文件流

1.使用elementui上传组件 要做一个选择文件后&#xff0c;先不上传&#xff0c;等最后点击确定后&#xff0c;把file二进制流及附加参数一起提交上去。 首先使用elementui中的上传组件&#xff0c;设置auto-uploadfalse&#xff0c;也就是选择文件后不立刻上传。 <el-uplo…

【学习笔记】卷积网络简介及原理探析

作者选择了由 Ian Goodfellow、Yoshua Bengio 和 Aaron Courville 三位大佬撰写的《Deep Learning》(人工智能领域的经典教程&#xff0c;深度学习领域研究生必读教材),开始深度学习领域学习&#xff0c;深入全面的理解深度学习的理论知识。 之前的文章参考下面的链接&#xf…

element-plus中Cascader级联选择器组件的使用

目录 一.基本使用 二.进阶使用 1.如何获取最后一级选项的值&#xff1f; 2.如何让级联选择器的输入框只展示最后一级&#xff1f; 三.实战 1.场景描述 2.实现步骤 ①设计后端返回值Vo ②编写controller ③编写service ④编写mapper层 ⑤在前端&#xff0c;通过发送…

【华为Pura先锋盛典】华为Pura X“阔折叠”手机发布:首次全面搭载HarmonyOS 5

文章目录 前言一、阔感体验&#xff0c;大有不同二、鸿蒙AI&#xff0c;大有智慧三、便携出行&#xff0c;大有不同四、首款全面搭载 HarmonyOS 5 的手机五、卓越性能&#xff0c;可靠安心六、红枫影像&#xff0c;大放光彩预热&#xff1a;鸿蒙电脑HarmonyOS 5 升级计划小结 前…

MQ,RabbitMQ,MQ的好处,RabbitMQ的原理和核心组件,工作模式

1.MQ MQ全称 Message Queue&#xff08;消息队列&#xff09;&#xff0c;是在消息的传输过程中 保存消息的容器。它是应用程序和应用程序之间的通信方法 1.1 为什么使用MQ 在项目中&#xff0c;可将一些无需即时返回且耗时的操作提取出来&#xff0c;进行异步处理&#xff0…

ETL:数据清洗、规范化和聚合的重要性

在当今这个数据呈爆炸式增长的时代&#xff0c;数据已成为企业最为宝贵的资产之一。然而&#xff0c;数据的海量增长也伴随着诸多问题&#xff0c;如数据来源多样、结构复杂以及质量问题等&#xff0c;这些问题严重阻碍了数据的有效处理与深度分析。在此背景下&#xff0c;ETL&…

电机控制常见面试问题(十八)

文章目录 一.电机控制高级拓扑结构1.LLC 二.谈谈电压器饱和后果三.电压器绕组连接方式的影响四.有源逆变的条件 一.电机控制高级拓扑结构 1.LLC LLC是什么&#xff1f;—— 一个会"变魔术"的电源盒子 想象你有一个魔法盒子&#xff0c;能把电池的电压变大或变小&…

stable diffusion本地安装

1. 基本环境准备 安装conda 环境 pytorch基础学习-CSDN博客 创建虚拟环境&#xff1a; conda create -n sd python3.10 一定要指定用3.10&#xff0c;过高的版本会提示错误&#xff1a; 激活启用环境&#xff1a; conda activate sd 设置pip国内镜像源&#xff1a; pip conf…

【内网穿透】Linux部署FRP0.61.2实现rk3566 Wechat iPad协议内网穿透教程

写在前面 FRP&#xff08;Fast Reverse Proxy&#xff09;是一个由Go语言编写的开源项目&#xff0c;用于内网穿透&#xff0c;即通过公网服务器将内网服务暴露给外部访问。这对于需要在内网环境中部署但又希望外部用户能够访问这些服务的场景非常有用 Github&#xff1a;htt…

VM虚拟机安装Ubuntu系统

前言 我现在装的Ubuntu总是死机&#xff0c;经常黑屏&#xff0c;所以我决定换个版本&#xff0c;顺便写一下笔记&#xff0c;给大家分享如何安装虚拟机 下载 这里我选择的是Ubuntu 22.04.5 LTS&#xff0c;下载链接&#xff1a;Ubuntu 22.04.5 LTS 如果访问不了网站的话&…

从JVM底层揭开Java方法重载与重写的面纱:原理、区别与高频面试题突破

&#x1f31f;引言&#xff1a;一场由方法调用引发的"血案" 2018年&#xff0c;某电商平台在"双十一"大促期间遭遇严重系统故障。 技术团队排查发现&#xff0c;问题根源竟是一个继承体系中的方法重写未被正确处理&#xff0c;导致订单金额计算出现指数级…