Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>

<head>
  <title>MetaMask and TatumSDK</title>
</head>

<body>
  <div id="container">
    <div class="card" id="signin">
      <h2>Mint Your Token With Tatum</h2>
      <p>Start by connecting your metamask wallet using the Sepolia Ethereum testnet.</p>
      <button class="btn" id="signIn">Connect Wallet</button>
    </div>
    <div class="card hidden" id="form">
      <h3>Enter the name, symbol, decimals and initial supply of your Fungible (ERC-20) token.</h3>
      <form onsubmit="create(); return false;">
        <label for="name">Name:</label>
        <input type="text" id="name" placeholder="Enter the name of the token" />
        <label for="symbol">Symbol:</label>
        <input type="text" id="symbol" placeholder="Enter the symbol of the token" />
        <label for="decimals">Decimals:</label>
        <input type="number" min=0 max=30 step=1 id="decimals" placeholder="Enter the decimals of the token" />
        <label for="supply">Initial supply:</label>
        <input type="text" id="supply" placeholder="Enter the initial supply of the token" />
        <button type="submit" class="btn">Create</button>
      </form>
    </div>
    <div class="card hidden" id="tx">
      <h2>Transaction result from MetaMask</h2>
      <div id="hash"></div><br/>
      <button class="btn" onclick="getContractAddress()">Get contract address</button><br/><br/>
      <div id="contractAddress"></div>      
    </div>
  </div>

</body>

</html>
              
            
!

CSS

              
                /* Center the container in the middle of the page */
#container {
  position: absolute;
  font-family: Poppins, sans-serif;
}

.hidden {
  display: none;
}

/* Style the cards */
.card {
  background-color: white;
  border-radius: 5px;
  margin-left: 10px;
  padding: 10px;
  text-align: left;
  width: 380px;
  margin-bottom: 20px;
}

/* Style the button */
  .btn {
    font-family: Poppins, sans-serif;
    width: 50%;
    padding: 10px 20px;
    font-size: 18px;
    border-radius: 5px;
    border: 1px solid transparent;
    background-color: #4237ff;
    margin-top: 15px;
    color: white;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
  }

/* Style the address element */
#address,
#hash {
  font-size: 16px;
  margin-top: 10px;
}

/* Style the result element */
#result {
  font-size: 24px;
  font-weight: bold;
  margin-top: 20px;
}

/* Style the address and amount inputs */
input[type="text"],
input[type="number"] {
  padding: 10px;
  margin: 10px;
  border: none;
  width: 400px;
  border-radius: 5px;
}

/* Style the form labels */
label {
  display: block;
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 5px;
  text-align: left;
}

form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
              
            
!

JS

              
                import { TatumSDK, Network, MetaMask } from "https://cdn.skypack.dev/@tatumio/tatum";

const tatum = await TatumSDK.init({ network: Network.ETHEREUM_SEPOLIA });

let address, txId;
const button = document.getElementById("signIn");

// Function to sign in with MetaMask
button.addEventListener("click", async () => {
  console.log("Signin");
  const metamaskAccount: string = await tatum.walletProvider.use(MetaMask).getWallet();
  
  console.log(`Connected address is ${metamaskAccount}`);
  document.getElementById("form").classList.remove("hidden");
  document.getElementById("signin").classList.add("hidden");
});

window.create = async () => {
  const name = document.querySelector("#name").value;
  const symbol = document.querySelector("#symbol").value;
  const decimals = parseInt(document.querySelector("#decimals").value);
  const initialSupply = document.querySelector("#supply").value;
  try {
    txId = await tatum.walletProvider.use(MetaMask).createFungibleToken(
      {name, symbol, decimals, initialSupply}
    );
    console.log(txId);
    document.querySelector("#hash").textContent = txId;
    document.getElementById("tx").classList.remove("hidden");
    document.getElementById("form").classList.add("hidden");
  } catch (e) {
    console.error(e);
    alert("Unable to sign and deploy transaction.");
  }
};

window.getContractAddress = async () => {
  const contractAddress = await tatum.rpc.getContractAddress(txId);
  document.querySelector("#contractAddress").textContent =
    contractAddress ||
    "Transaction not yet included in the block. Try again later.";
};
              
            
!
999px

Console