How to understand the blockchain integration code found in memberstack.js? Answered

Post author
Anton Seledets

Dear Memberstack Support Team,

I hope this message finds you well.

I recently reviewed the memberstack.js file that you provide for use with vanilla JavaScript, accessible via this path: https://static.memberstack.com/scripts/v1/memberstack.js.

While inspecting the contents, I noticed some unexpected code sections that seem to handle blockchain interactions. Here’s an excerpt from the code:

class s {
  constructor(e) {
    this.options = e;
    this.apiKey = this.options.apiKey;
    this.channel = this.options.channelId;
    this.blockchainTestMode = this.options.blockchainTestMode;
    this.blockchainGasFee = this.options.blockchainGasFee;
    this.blockchainTestMode ? (this.contractAddress = "0x2321c321828946153a845e69ee168f413e85c90d") : (this.contractAddress = "0x2a840CA40E082DbF24610B62a978900BfCaB23D3");
  }

  async init() {
    const e = new Web3(window.ethereum),
          t = await ethereum.request({ method: "eth_requestAccounts" });
    this.account = t[0];
    this.contract = new e.eth.Contract(r.HV, this.contractAddress);
  }

  checkWeb3() {
    return "undefined" == typeof Web3 ? (console.log("Web3.js is not installed!"), !1) : void 0 !== window.ethereum || (console.log("MetaMask is not installed!"), !1);
  }

  // other methods for interacting with the blockchain
}

Based on this, it appears that the script includes features for blockchain transactions, including confirming and sending transactions and interacting with the MetaMask extension.

Could you please clarify the purpose of this code within the memberstack.js file? Specifically, I am curious if these blockchain features are part of the standard Memberstack functionality or if they are intended for a specific type of integration.

Thank you in advance for your assistance. I look forward to your response.

Best regards,
Anton

Comments

1 comment

  • Comment author
    Josh Lopez

    Hey Anton Seledets

    Thank you for posting. I did some digging and this is coming from a package we are using for realtime updates specifically the piesocket-js package. Nothing to be worried about.

    1

Please sign in to leave a comment.