หลังจากบทความก่อนหน้า “สอนสร้างเหรียญคริปโต(ERC20)แบบจับมือทำ ปฐมบทแห่งBlockchain” ที่เราสร้างเหรียญคริปโตด้วยตัวเองไปแล้ว วันนี้ก็จะเป็นบทความต่อยอดโดยการที่เราจะเพิ่มรูปภาพโลโก้ให้เหรียญที่เราสร้างขึ้นมาใหม่ให้เป็นรูปภาพที่เราต้องการ ไปชมกันเล้ยยย
File : HTML
<button onclick="addTokenFunction()">Add Token</button>
File : JS
if(typeof window.ethereum !== 'undefined') { console.log('MetaMask is installed') } const tokenAddress = "0x6e0076e1eBab350A528848e590FA993108FB562a" const tokenSymbol = 'BLP' const tokenDecimals = 18 const tokenImage = 'https://i.ibb.co/RB9J4Kb/logo-v2.png' async function addTokenFunction() { try { const wasAdded = await ethereum.request({ method:'wallet_watchAsset', params:{ type:'ERC20', options:{ address:tokenAddress, symbol: tokenSymbol, decimals: tokenDecimals, image: tokenImage }, }, }); if (wasAdded) { console.log('Token added successfully.') } else { console.log('Token was not added.') } } catch (error) { console.log(error) } }