投稿時間:2022-02-10 22:29:48 RSSフィード2022-02-10 22:00 分まとめ(32件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT ITmedia 総合記事一覧 [ITmedia ビジネスオンライン] 福岡県の「街の住みここち沿線ランキング」 3位「JR筑肥線」、2位「地下鉄空港線」、1位は? https://www.itmedia.co.jp/business/articles/2202/10/news162.html itmedia 2022-02-10 21:15:00
IT ITmedia 総合記事一覧 [ITmedia News] ポケモンGOに「フラベベ」初登場 バレンタインイベントで 「トリミアン」のハートカットも https://www.itmedia.co.jp/news/articles/2202/10/news180.html itmedia 2022-02-10 21:09:00
python Pythonタグが付けられた新着投稿 - Qiita gRPC を Envoy でプロキシして Python から使う【2022】 https://qiita.com/SogoK/items/35203bc7326bdd55d276 これはPythonのgrpcioが使っているライブラリがALPNを要求しているためGoLangでは必要とされていないに発生しているエラーなので、サーバー側でALPNを有効にすることで直ります。 2022-02-10 21:12:27
AWS AWSタグが付けられた新着投稿 - Qiita 【AWS】 ECSでコンテナのヘルスチェックの欄に書くコマンド https://qiita.com/manten120/items/8dad97550685532715cc 【AWS】ECSでコンテナのヘルスチェックの欄に書くコマンドタスク定義で、コンテナの編集のヘルスチェックの欄には下のようなコマンドを書く。 2022-02-10 21:56:49
AWS AWSタグが付けられた新着投稿 - Qiita Redshift-managed VPC endpointsを構築してみた https://qiita.com/yes_dog/items/a47181b79d45a87f94e7 psqlhltRedshiftmanagedVPCendpointsのエンドポイントURLgtUawsuserpdltデータベース名gt作成後の疑問点で確認した際に、IPアドレスがつしか割り当てられていなかったので、AZ障害時の挙動に関して、AWSサポートに問い合わせをしました。 2022-02-10 21:20:57
golang Goタグが付けられた新着投稿 - Qiita # 【Go】一人コードリーディング会を始めます。(2回目) https://qiita.com/endo-yuki/items/6286b5462fed60b5a41d コードリーディング会とは何人かで同じコードを各々で読んで、発見を共有して理解を深めましょうというのが趣旨と理解しています。 2022-02-10 21:42:40
Git Gitタグが付けられた新着投稿 - Qiita 複数のGitHubアカウントの自動切り替え設定 https://qiita.com/daishiman/items/78f870f12d8d60e136b9 configファイルにサブアカウントを設定するGitHubに作成した公開鍵が設定できたので次は、サブアカウントの情報をsshディレクトリのconfigファイルに、サブアカウントの情報を設定します。 2022-02-10 21:53:03
技術ブログ Developers.IO S3 バッチレプリケーションで既存オブジェクトの同期を試してみた https://dev.classmethod.jp/articles/s3-batch-replication-existing-objects/ amazonsbatchreplication 2022-02-10 12:23:30
海外TECH MakeUseOf A Simple Trick for Cleaning Under Your Keyboard's Keys https://www.makeuseof.com/tag/a-simple-trick-for-cleaning-under-your-keyboards-keys/ keyscleaning 2022-02-10 12:29:05
海外TECH MakeUseOf What Is a Cryptocurrency Mining Motherboard? https://www.makeuseof.com/what-is-a-cryptocurrency-mining-motherboard/ cryptocurrency 2022-02-10 12:00:38
海外TECH DEV Community Create Windows Loader Using CSS https://dev.to/rohithaditya/create-windows-loader-using-css-3djp Create Windows Loader Using CSSDo You Love windows Loading Animation If Yes Then its for you HTML CODE lt div class container gt lt div class loader wrapper gt lt div class loader gt lt div class dot gt lt div gt lt div gt lt div class loader gt lt div class dot gt lt div gt lt div gt lt div class loader gt lt div class dot gt lt div gt lt div gt lt div class loader gt lt div class dot gt lt div gt lt div gt lt div class loader gt lt div class dot gt lt div gt lt div gt lt div class loader gt lt div class dot gt lt div gt lt div gt lt div gt lt div class bot gt lt br gt Loading lt div gt lt div gt The Following Are CSS CODE body margin display grid place items center height vh background color aed container width px height px display grid place items center loader wrapper width px height px position absolute display flex justify content center align items center loader position absolute height px animation spin s linear infinite loader dot width px height px background color fff border radius position relative top px keyframes spin transform rotate deg opacity transform rotate deg opacity transform rotate deg opacity opacity transform rotate deg loader first child animation delay s loader nth child animation delay s loader nth child animation delay s loader nth child animation delay s loader nth child animation delay s loader last child animation delay s bot display flex margin top color white font size px font family Raleway For Demo 2022-02-10 12:50:39
海外TECH DEV Community The Complete Guide to Full Stack Web3 Development https://dev.to/dabit3/the-complete-guide-to-full-stack-web3-development-4g74 The Complete Guide to Full Stack Web Development Building a full stack web app with Next js Polygon Solidity The Graph IPFS and HardhatIn this in depth tutorial you ll learn the tools protocols and frameworks for building full stack web apps and most importantly how to put everything together to lay the groundwork for building out any of your own ideas in the future The codebase for this app is located hereThe main network we ll be deploying to is Polygon I chose Polygon because of its low transaction cost fast block times and current network adoption That being said we re going to be building on the Ethereum Virtual Machine EVM so you can apply these skills to build for dozens of other blockchain networks as well including Ethereum Celo Avalanche and many others The app we ll be building is a full stack blog as well as a content management system CMS meaning that you will have an open public and composable back end that can be transferred and reused anywhere By the end of this tutorial you should have a good understanding of the most important pieces of a modern web stack and how to build performant scalable full stack decentralized blockchain applications This is the third guide in my Full Stack web series Also be sure to check out The Complete Guide to Full Stack Ethereum DevelopmentBuilding a Full Stack NFT Marketplace on Ethereum with Polygon The web stackIn Defining the web stack I wrote about my interpretation of the current state of the web tech stack from a developer s perspective using a combination of my own personal experience as well as research that was done over the past year on my team at Edge amp Node We will be using pieces of this stack for this application Blockchain Polygon with optional RPC provider Ethereum development environment HardhatFront end framework Next js amp ReactEthereum web client library Ethers jsFile storage IPFSIndexing and querying The Graph ProtocolLearning how to use these building blocks we can build out many types of applications so the goal with this tutorial is to show how they each work and how they all fit together Let s get started PrerequisitesNode js installed on your local machineMetaMask Chrome extension installed in your browser Project setupHere we will create the application boilerplates install all of the necessary dependencies and configure the project The code will be commented to give you insight as to what is happening and I ll describe some of what is going on throughout the tutorial as well To get started create a new Next js application and change into the new directory npx create next app web blogcd web blogNext change into the new directory and install the following dependencies using either npm yarn or pnpm npm install ethers hardhat nomiclabs hardhat waffle ethereum waffle chai nomiclabs hardhat ethers webmodal walletconnect web provider easymde react markdown react simplemde editor ipfs http client emotion css openzeppelin contractsAn overview of some of these dependencies hardhat Ethereum development environmentwebmodal An easy to use library that allows users to connect their wallets to your appreact markdown and simplemde Markdown editor and markdown renderer for the CMS emotion css A great CSS in JS library openzeppelin contracts Open source implementations of useful smart contract standards and functionalityNext we ll initialize the local smart contract development environment npx hardhat What do you want to do Create a sample project Hardhat project root lt Choose default path gt This should scaffold out the basic Solidity development environment that we will use You should see a few new files and folders created including contracts scripts test and hardhat config js Next let s update the hardhat configuration at hardhat config js Update this file with the following code require nomiclabs hardhat waffle module exports solidity networks hardhat chainId mumbai url accounts process env pk polygon url accounts process env pk Here we ve configured the local hardhat development environment as well as set up and commented out the Polygon mainnet and Mumbai testnet environments that we ll be using to deploy to Polygon Next let s add some basic global CSS that we ll be needing to style the markdown editor for the CMS Open styles globals css and add the following code below the existing css EasyMDEContainer editor toolbar border none EasyMDEContainer CodeMirror border none important background none editor preview background color white important CodeMirror cm spell error not cm url not cm comment not cm tag not cm word background color transparent important pre padding px background color efefef blockquote border left px solid ddd padding left px margin left px Next we ll create a couple of SVG files for the app images one for the logo and one as an arrow button Create logo svg and right arrow svg in the public folder and copy the linked SVG code into each of those files The smart contractNext let s create the smart contract that will be powering our blog and CMS Create a new file in the contracts folder named Blog sol Here add the following code contracts Blog sol SPDX License Identifier Unlicensepragma solidity import hardhat console sol import openzeppelin contracts utils Counters sol contract Blog string public name address public owner using Counters for Counters Counter Counters Counter private postIds struct Post uint id string title string content bool published mappings can be seen as hash tables here we create lookups for posts by id and posts by ipfs hash mapping uint gt Post private idToPost mapping string gt Post private hashToPost events facilitate communication between smart contractsand their user interfaces i e we can create listeners for events in the client and use them in The Graph event PostCreated uint id string title string hash event PostUpdated uint id string title string hash bool published when the blog is deployed give it a name also set the creator as the owner of the contract constructor string memory name console log Deploying Blog with name name name name owner msg sender updates the blog name function updateName string memory name public name name transfers ownership of the contract to another address function transferOwnership address newOwner public onlyOwner owner newOwner fetches an individual post by the content hash function fetchPost string memory hash public view returns Post memory return hashToPost hash creates a new post function createPost string memory title string memory hash public onlyOwner postIds increment uint postId postIds current Post storage post idToPost postId post id postId post title title post published true post content hash hashToPost hash post emit PostCreated postId title hash updates an existing post function updatePost uint postId string memory title string memory hash bool published public onlyOwner Post storage post idToPost postId post title title post published published post content hash idToPost postId post hashToPost hash post emit PostUpdated post id title hash published fetches all posts function fetchPosts public view returns Post memory uint itemCount postIds current uint currentIndex Post memory posts new Post itemCount for uint i i lt itemCount i uint currentId i Post storage currentItem idToPost currentId posts currentIndex currentItem currentIndex return posts this modifier means only the contract owner can invoke the function modifier onlyOwner require msg sender owner This contract allows the owner to create and edit posts and for anyone to fetch posts To make this smart contract permissionless you could remove the onlyOwner modifier and use The Graph to index and query posts by owner Next let s write a basic test to test out the most important functionality we ll be using To do so open test sample test js and update it with the following code const expect require chai const ethers require hardhat describe Blog async function it Should create a post async function const Blog await ethers getContractFactory Blog const blog await Blog deploy My blog await blog deployed await blog createPost My first post const posts await blog fetchPosts expect posts title to equal My first post it Should edit a post async function const Blog await ethers getContractFactory Blog const blog await Blog deploy My blog await blog deployed await blog createPost My Second post await blog updatePost My updated post true posts await blog fetchPosts expect posts title to equal My updated post it Should add update the name async function const Blog await ethers getContractFactory Blog const blog await Blog deploy My blog await blog deployed expect await blog name to equal My blog await blog updateName My new blog expect await blog name to equal My new blog Next run the test by opening your terminal and running this command npx hardhat test Deploying the contractNow that the contract has been written and tested let s try to deploy it to a local test network To start the local network open your terminal at least two separate windows In one window run the following script npx hardhat nodeWhen we run this command you should see a list of addresses and private keys These are test accounts and addresses created for us that we can use to deploy and test our smart contracts Each account is also loaded up with fake Ether In a moment we ll learn how to import the test account into MetaMask so that we can use it Next we need to deploy the contract to the test network First update the name of scripts sample script js to scripts deploy js Next update the file with this new deploy script scripts deploy js const hre require hardhat const fs require fs async function main these two lines deploy the contract to the network const Blog await hre ethers getContractFactory Blog const blog await Blog deploy My blog await blog deployed console log Blog deployed to blog address this code writes the contract addresses to a local file named config js that we can use in the app fs writeFileSync config js export const contractAddress blog address export const ownerAddress blog signer address main then gt process exit catch error gt console error error process exit Now in a separate window while the local network is still running we can run the deploy script and give a flag to the CLI that we would like to deploy to our local network npx hardhat run scripts deploy js network localhostWhen the contract is deployed you should see some output in your network terminal Importing the test account into your walletTo send transactions to the smart contract we will need to connect our MetaMask wallet using one of the accounts created when we ran npx hardhat node In the list of contracts that the CLI logs out you should see both an Account number as well as a Private Key ➜react dapp git main npx hardhat nodeStarted HTTP and WebSocket JSON RPC server at Accounts Account xffdeaadffceabcfffb ETH Private Key xacbecaebaabdffbacbcbedefcaedbffff We can import this account into MetaMask in order to start using some of the fake Eth available there To do so first open MetaMask and enable test networks Next update the network to be Localhost Next in MetaMask click on Import Account from the accounts menu Copy then paste the very first Private Key logged out by the CLI and click Import Once the account is imported you should see the Eth in the account Be sure you imported the first account in the list of accounts Account as this will be the account used by default when the contract is deployed and therefore the contract owner Now that we have a smart contract deployed and an account ready to use we can start interacting with it from the Next js app The Next js appNext let s write the code for the app The first thing we ll do is set up a couple of environment variables that we ll use to switch between a local testing environment Mumbai testnet and Polygon mainnet Create a new file named env local in the root of your project and add the following configuration to start with ENVIRONMENT local NEXT PUBLIC ENVIRONMENT local We will be able to switch these variables between local testnet and mainnet to switch between This will allow us to reference our environment both on the client as well as the server To learn more about how environment variables work in Next js check out the documentation here context jsNext let s create the app context Context will give us an easy way to share state throughout the app Create a file named context js and add the following code import createContext from react export const AccountContext createContext null Layout and NavNext let s open up pages app js Here we will update the code to include navigation wallet connection context and some basic styling This page serves as a wrapper or layout for the rest of the app pages app js import styles globals css import useState from react import Link from next link import css from emotion css import ethers from ethers import WebModal from webmodal import WalletConnectProvider from walletconnect web provider import AccountContext from context js import ownerAddress from config import easymde dist easymde min css function MyApp Component pageProps create local state to save account information after signin const account setAccount useState null webModal configuration for enabling wallet access async function getWebModal const webModal new WebModal network mainnet cacheProvider false providerOptions walletconnect package WalletConnectProvider options infuraId process env NEXT PUBLIC INFURA ID return webModal the connect function uses web modal to connect to the user s wallet async function connect try const webModal await getWebModal const connection await webModal connect const provider new ethers providers WebProvider connection const accounts await provider listAccounts setAccount accounts catch err console log error err return lt div gt lt nav className nav gt lt div className header gt lt Link href gt lt a gt lt img src logo svg alt React Logo style width px gt lt a gt lt Link gt lt Link href gt lt a gt lt div className titleContainer gt lt h className title gt Full Stack lt h gt lt p className description gt WEB lt p gt lt div gt lt a gt lt Link gt account amp amp lt div className buttonContainer gt lt button className buttonStyle onClick connect gt Connect lt button gt lt div gt account amp amp lt p className accountInfo gt account lt p gt lt div gt lt div className linkContainer gt lt Link href gt lt a className link gt Home lt a gt lt Link gt if the signed in user is the contract owner we show the nav link to create a new post account ownerAddress amp amp lt Link href create post gt lt a className link gt Create Post lt a gt lt Link gt lt div gt lt nav gt lt div className container gt lt AccountContext Provider value account gt lt Component pageProps connect connect gt lt AccountContext Provider gt lt div gt lt div gt const accountInfo css width display flex flex justify content flex end font size px const container css padding px const linkContainer css padding px px background color fafafa const nav css background color white const header css display flex border bottom px solid rgba padding px px const description css margin color const titleContainer css display flex flex direction column padding left px const title css margin left px font weight margin const buttonContainer css width display flex flex justify content flex end const buttonStyle css background color fafafa outline none border none font size px padding px px border radius px cursor pointer box shadow px px rgba const link css margin px px px px font size px font weight export default MyApp EntrypointNow that we have the layout set up let create the entrypoint to the app This page will fetch the list of posts from the network and render the post titles in a listview When the user clicks on a post we will navigate them to another page for a detail view page will be created next pages index js import css from emotion css import useContext from react import useRouter from next router import ethers from ethers import Link from next link import AccountContext from context import contract address and contract owner address import contractAddress ownerAddress from config import Application Binary Interface ABI import Blog from artifacts contracts Blog sol Blog json export default function Home props posts are fetched server side and passed in as props see getServerSideProps const posts props const account useContext AccountContext const router useRouter async function navigate router push create post return lt div gt lt div className postList gt map over the posts array and render a button with the post title posts map post index gt lt Link href post post key index gt lt a gt lt div className linkStyle gt lt p className postTitle gt post lt p gt lt div className arrowContainer gt lt img src right arrow svg alt Right arrow className smallArrow gt lt div gt lt div gt lt a gt lt Link gt lt div gt lt div className container gt account ownerAddress amp amp posts amp amp posts length amp amp if the signed in user is the account owner render a button to create the first post lt button className buttonStyle onClick navigate gt Create your first post lt img src right arrow svg alt Right arrow className arrow gt lt button gt lt div gt lt div gt export async function getServerSideProps here we check to see the current environment variable and render a provider based on the environment we re in let provider if process env ENVIRONMENT local provider new ethers providers JsonRpcProvider else if process env ENVIRONMENT testnet provider new ethers providers JsonRpcProvider else provider new ethers providers JsonRpcProvider const contract new ethers Contract contractAddress Blog abi provider const data await contract fetchPosts return props posts JSON parse JSON stringify data const arrowContainer css display flex flex justify content flex end padding right px const postTitle css font size px font weight bold cursor pointer margin padding px const linkStyle css border px solid ddd margin top px border radius px display flex const postList css width px margin auto padding top px const container css display flex justify content center const buttonStyle css margin top px background color fafafa outline none border none font size px padding px px border radius px cursor pointer box shadow px px rgba const arrow css width px margin left px const smallArrow css width px Creating postsNext create a new file in the pages directory named create post js This will hold the route that will allow us to create posts and save them to the network We ll also have the option to upload and save a cover image to IPFS with the hash of the ipfs upload anchored on chain with the rest of the most data Add the following code to this file pages create post js import useState useRef useEffect from react newimport useRouter from next router import dynamic from next dynamic import css from emotion css import ethers from ethers import create from ipfs http client import contract address and contract owner address import contractAddress from config import Blog from artifacts contracts Blog sol Blog json define the ipfs endpoint const client create api v configure the markdown editor to be client side import const SimpleMDE dynamic gt import react simplemde editor ssr false const initialState title content function CreatePost configure initial state to be used in the component const post setPost useState initialState const image setImage useState null const loaded setLoaded useState false const fileRef useRef null const title content post const router useRouter useEffect gt setTimeout gt delay rendering buttons until dynamic import is complete setLoaded true function onChange e setPost gt post e target name e target value async function createNewPost saves post to ipfs then anchors to smart contract if title content return const hash await savePostToIpfs await savePost hash router push async function savePostToIpfs save post metadata to ipfs try const added await client add JSON stringify post return added path catch err console log error err async function savePost hash anchor post to smart contract if typeof window ethereum undefined const provider new ethers providers WebProvider window ethereum const signer provider getSigner const contract new ethers Contract contractAddress Blog abi signer console log contract contract try const val await contract createPost post title hash optional wait for transaction to be confirmed before rerouting await provider waitForTransaction val hash console log val val catch err console log Error err function triggerOnChange trigger handleFileChange handler of hidden file input fileRef current click async function handleFileChange e upload cover image to ipfs and save hash to state const uploadedFile e target files if uploadedFile return const added await client add uploadedFile setPost state gt state coverImage added path setImage uploadedFile return lt div className container gt image amp amp lt img className coverImageStyle src URL createObjectURL image gt lt input onChange onChange name title placeholder Give it a title value post title className titleStyle gt lt SimpleMDE className mdEditor placeholder What s on your mind value post content onChange value gt setPost post content value gt loaded amp amp lt gt lt button className button type button onClick createNewPost gt Publish lt button gt lt button onClick triggerOnChange className button gt Add cover image lt button gt lt gt lt input id selectImage className hiddenInput type file onChange handleFileChange ref fileRef gt lt div gt const hiddenInput css display none const coverImageStyle css max width px const mdEditor css margin top px const titleStyle css margin top px border none outline none background color inherit font size px font weight amp placeholder color const container css width px margin auto const button css background color fafafa outline none border none border radius px cursor pointer margin right px font size px padding px px box shadow px px rgba export default CreatePost Viewing a postNow that we have the ability to create posts how do we navigate and view posts We want to have the ability to view a post in a route that looks something like myapp com post some post id We can do this in a couple of different ways with next js dynamic routes We will be leveraging server side data fetching using getStaticPaths and getStaticProps which will create these pages at build time using the array of posts queried from the network To make this happen create a new folder in the pages directory named posts and a file in that folder named id js There add the following code pages post id js import ReactMarkdown from react markdown import useContext from react import useRouter from next router import Link from next link import css from emotion css import ethers from ethers import AccountContext from context import contract and owner addresses import contractAddress ownerAddress from config import Blog from artifacts contracts Blog sol Blog json const ipfsURI export default function Post post const account useContext AccountContext const router useRouter const id router query if router isFallback return lt div gt Loading lt div gt return lt div gt post amp amp lt div className container gt if the owner is the user render an edit button ownerAddress account amp amp lt div className editPost gt lt Link href edit post id gt lt a gt Edit post lt a gt lt Link gt lt div gt if the post has a cover image render it post coverImage amp amp lt img src post coverImage className coverImageStyle gt lt h gt post title lt h gt lt div className contentContainer gt lt ReactMarkdown gt post content lt ReactMarkdown gt lt div gt lt div gt lt div gt export async function getStaticPaths here we fetch the posts from the network let provider if process env ENVIRONMENT local provider new ethers providers JsonRpcProvider else if process env ENVIRONMENT testnet provider new ethers providers JsonRpcProvider else provider new ethers providers JsonRpcProvider const contract new ethers Contract contractAddress Blog abi provider const data await contract fetchPosts then we map over the posts and create a params object passing the id property to getStaticProps which will run for ever post in the array and generate a new page const paths data map d gt params id d return paths fallback true export async function getStaticProps params using the id property passed in through the params object we can us it to fetch the data from IPFS and pass the post data into the page as props const id params const ipfsUrl ipfsURI id const response await fetch ipfsUrl const data await response json if data coverImage let coverImage ipfsURI data coverImage data coverImage coverImage return props post data const editPost css margin px px const coverImageStyle css width px const container css width px margin auto const contentContainer css margin top px padding px px border left px solid eee border right px solid eee amp img max width px Editing a postThe final page we need to create is a way to edit existing posts This page will carry over some functionality from both pages create post js as well as pages post id js We will be able to toggle between viewing and editing a post Create a new folder in the pages directory named edit post and a file named id js there Next add the following code pages edit post id js import useState useEffect from react import useRouter from next router import ReactMarkdown from react markdown import css from emotion css import dynamic from next dynamic import ethers from ethers import create from ipfs http client import contractAddress from config import Blog from artifacts contracts Blog sol Blog json const ipfsURI const client create api v const SimpleMDE dynamic gt import react simplemde editor ssr false export default function Post const post setPost useState null const editing setEditing useState true const router useRouter const id router query useEffect gt fetchPost id async function fetchPost we first fetch the individual post by ipfs hash from the network if id return let provider if process env NEXT PUBLIC ENVIRONMENT local provider new ethers providers JsonRpcProvider else if process env NEXT PUBLIC ENVIRONMENT testnet provider new ethers providers JsonRpcProvider else provider new ethers providers JsonRpcProvider const contract new ethers Contract contractAddress Blog abi provider const val await contract fetchPost id const postId val toNumber next we fetch the IPFS metadata from the network const ipfsUrl ipfsURI id const response await fetch ipfsUrl const data await response json if data coverImage let coverImagePath ipfsURI data coverImage data coverImagePath coverImagePath finally we append the post ID to the post data we need this ID to make updates to the post data id postId setPost data async function savePostToIpfs try const added await client add JSON stringify post return added path catch err console log error err async function updatePost const hash await savePostToIpfs const provider new ethers providers WebProvider window ethereum const signer provider getSigner const contract new ethers Contract contractAddress Blog abi signer await contract updatePost post id post title hash true router push if post return null return lt div className container gt editing state will allow the user to toggle between a markdown editor and a markdown renderer editing amp amp lt div gt lt input onChange e gt setPost post title e target value name title placeholder Give it a title value post title className titleStyle gt lt SimpleMDE className mdEditor placeholder What s on your mind value post content onChange value gt setPost post content value gt lt button className button onClick updatePost gt Update post lt button gt lt div gt editing amp amp lt div gt post coverImagePath amp amp lt img src post coverImagePath className coverImageStyle gt lt h gt post title lt h gt lt div className contentContainer gt lt ReactMarkdown gt post content lt ReactMarkdown gt lt div gt lt div gt lt button className button onClick gt setEditing editing false true gt editing View post Edit post lt button gt lt div gt const button css background color fafafa outline none border none border radius px cursor pointer margin right px margin top px font size px padding px px box shadow px px rgba const titleStyle css margin top px border none outline none background color inherit font size px font weight amp placeholder color const mdEditor css margin top px const coverImageStyle css width px const container css width px margin auto const contentContainer css margin top px padding px px border left px solid eee border right px solid eee amp img max width px Testing it outWe can now test it out To do so be sure you have already deployed the contract to the network in the previous steps and you still have the local network running Open a new terminal window and start the Next js app npm run devWhen the app starts you should be able to connect your wallet and interact with the app You should also be able to create a new post You may notice that the app is not as fast as it could be but Next js is blazingly fast in production To run a production build run the following commands npm run build amp amp npm start Deploying to PolygonNow that we have the project up and running and tested locally let s deploy to Polygon We ll start by deploying to Mumbai the Polygon test network The first thing we will need to do is set one of our private keys from our wallet as an environment variable To get a private key you can export them directly from MetaMask Private keys are never meant to be shared publicly under any circumstance It is advised never to hardcode a private key in a file If you do choose to do so be sure to use a testing wallet and to never under any circumstances push a file containing a private key to source control or expose it publicly If you are on a Mac you can set an environment variable from the command line like so be sure to run the deploy script from this same terminal and session export pk your private key Configuring the networkNext we need to switch from the local test network to the Mumbai Testnet To do so we need to create and set the network configuration First open MetaMask and click on Settings Next click on Networks and then Add Network Here we will add the following configurations for the Mumbai test network as listed here Network Name Mumbai TestNetNew RPC URL Chain ID Currency Symbol MaticSave this then you should be able to switch to and use the new network Finally you will need some testnet Polygon tokens in order to interact with the applications To get these you can visit the Polygon Faucet inputting the address of the wallets that you would like to request the tokens Deploying to the Polygon networkNow that you have some tokens you can deploy to the Polygon network To do so be sure that the address associated with the private key you are deploying your contract with has received some tokens in order to pay the gas fees for the transaction Next uncomment the mumbai configuration in hardhat config js mumbai url accounts process env pk To deploy to Polygon testnet run the following command npx hardhat run scripts deploy js network mumbaiIf you run into this error ProviderError RPCError the public RPC may be congested In production it s recommended to use an RPC provider like Infura Alchemy or Quicknode Next update the environment variables in env local to be testnet ENVIRONMENT testnet NEXT PUBLIC ENVIRONMENT testnet Next restart the server to register the change in environment variables npm run devYou should now be able to test the app on the new network If you have any issues connecting to the public Mumbai RPC endpoint consider replacing the endpoints in your app using endpoints from an RPC provider like Infura Alchemy or Quicknode Creating a subgraph APIBy default the only data access patterns we have are the two functions we ve written into the contract fetchPost and fetchPosts This is a fine place to start but as your app starts to scale you ll probably find yourself needing a more flexible and scalable API For instance what if we wanted to give the user the ability to search posts fetch posts created by a certain user or to sort posts by the date which they were created We can build all of this functionality into an API by using The Graph protocol Let s see how to do this Creating the project in The GraphTo get started visit The Graph hosted service and either sign in or create a new account Next go to the dashboard and click on Add Subgraph to create a new subgraph Configure your subgraph with the following properties Subgraph Name BlogcmsSubtitle A subgraph for querying post dataOptional Fill the description and GITHUB URL propertiesOnce the subgraph is created we will initialize the subgraph locally using the Graph CLI Initializing a new subgraph using the Graph CLINext install the Graph CLI npm install g graphprotocol graph cli or yarn global add graphprotocol graph cliOnce the Graph CLI has been installed you can initialize a new subgraph with the Graph CLI init command Since we ve already deployed our contract to the network we can initialize from that contract address by passing in the contract address using the from contract flag This address is available for reference in config js as contractAddress graph init from contract your contract address network mumbai contract name Blog index events Protocol ethereum Product for which to initialize ›hosted service Subgraph name ›your username blogcms Directory to create the subgraph in ›blogcms Ethereum network ›mumbai Contract address ›your contract address ABI file path ›artifacts contracts Blog sol Blog json Contract Name ›BlogThis command will generate a basic subgraph based off of the contract address passed in as the argument to from contract By using this contract address the CLI will initialize a few things in your project to get you started including fetching the abis and saving them in the abis directory By passing in index events the CLI will automatically populate some code for us both in schema graphql as well as src mapping ts based on the events emitted from the contract The main configuration and definition for the subgraph lives in the subgraph yaml file The subgraph codebase consists of a few files subgraph yaml a YAML file containing the subgraph manifestschema graphql a GraphQL schema that defines what data is stored for your subgraph and how to query it via GraphQLAssemblyScript Mappings AssemblyScript code that translates from the event data in Ethereum to the entities defined in your schema e g mapping ts in this tutorial The entries in subgraph yaml that we will be working with are description optional a human readable description of what the subgraph is This description is displayed by the Graph Explorer when the subgraph is deployed to the Hosted Service repository optional the URL of the repository where the subgraph manifest can be found This is also displayed by the Graph Explorer dataSources source the address of the smart contract the subgraph sources and the abi of the smart contract to use The address is optional omitting it allows to index matching events from all contracts dataSources source startBlock optional the number of the block that the data source starts indexing from In most cases we suggest using the block in which the contract was created dataSources mapping entities the entities that the data source writes to the store The schema for each entity is defined in the the schema graphql file dataSources mapping abis one or more named ABI files for the source contract as well as any other smart contracts that you interact with from within the mappings dataSources mapping eventHandlers lists the smart contract events this subgraph reacts to and the handlers in the mapping ー src mapping ts in the example ーthat transform these events into entities in the store Defining the entitiesWith The Graph you define entity types in schema graphql and Graph Node will generate top level fields for querying single instances and collections of that entity type Each type that should be an entity is required to be annotated with an entity directive The entities data we will be indexing are the Token and User This way we can index the Tokens created by the users as well as the users themselves To do this update schema graphql with the following code type Schema fulltext name postSearch language en algorithm rank include entity Post fields name title name postContent type Post entity id ID title String contentHash String published Boolean postContent String createdAtTimestamp BigInt updatedAtTimestamp BigInt Now that we have created the GraphQL schema for our app we can generate the entities locally to start using in the mappings created by the CLI graph codegenIn order to make working smart contracts events and entities easy and type safe the Graph CLI generates AssemblyScript types from a combination of the subgraph s GraphQL schema and the contract ABIs included in the data sources Updating the subgraph with the entities and mappingsNow we can configure the subgraph yaml to use the entities that we have just created and configure their mappings To do so first update the dataSources mapping entities field with the User and Token entities entities PostNext we ll need to find the block which the contract was deployed optional We need this so that we can set the start block for the indexer to begin syncing so that it does not need to sync from the genesis block You can find the start block by visiting and pasting in your contract address Finally update the configuration to add the startBlock source address your contract adddress abi Blog startBlock your start block Assemblyscript mappingsNext open src mappings ts to write the mappings that we defined in our subgraph subgraph eventHandlers Update the file with the following code import PostCreated as PostCreatedEvent PostUpdated as PostUpdatedEvent from generated Blog Blog import Post from generated schema import ipfs json from graphprotocol graph ts export function handlePostCreated event PostCreatedEvent void let post new Post event params id toString post title event params title post contentHash event params hash let data ipfs cat event params hash if data let value json fromBytes data toObject if value const content value get content if content post postContent content toString post createdAtTimestamp event block timestamp post save export function handlePostUpdated event PostUpdatedEvent void let post Post load event params id toString if post post title event params title post contentHash event params hash post published event params published let data ipfs cat event params hash if data let value json fromBytes data toObject if value const content value get content if content post postContent content toString post updatedAtTimestamp event block timestamp post save These mappings will handle events for when a new post is created and when a post is updated When these events fire the mappings will save the data into the subgraph Running a buildNext let s run a build to make sure that everything is configured properly To do so run the build command graph buildIf the build is successful you should see a new build folder generated in your root directory Deploying the subgraphTo deploy we can run the deploy command To deploy you will first need to copy the Access token for your account available in the Graph Dashboard Next run the following command graph auth lt ACCESS TOKEN gt yarn deployOnce the subgraph is deployed you should see it show up in your dashboard When you click on the subgraph it should open the subgraph details Querying for dataNow that we are in the dashboard we should be able to start querying for data Run the following query to get a list of posts posts id title contentHash published postContent We can also configure the order direction by creation date posts orderBy createdAtTimestamp orderDirection desc id title contentHash published postContent We can also do full text search on the post title or content postSearch text Hello id title contentHash published postContent Congratulations you have now build out a more flexible API that you can use to query your app To learn how to use the API endpoint in your app check out the documentation here or the video here Next stepsIf you d like a challenge consider adding some functionality that will allow you to update the cover image in pages edit post id js If you d like to deploy your app and make it live check out Vercel If you enjoyed this tutorial be sure to check out my other two comprehensive guides The Complete Guide to Full Stack Ethereum DevelopmentBuilding a Full Stack NFT Marketplace on Ethereum with Polygon 2022-02-10 12:33:58
海外TECH DEV Community 3 Websites That Help To Understand More About Virtual Dom https://dev.to/jagannathkrishna/3-websites-that-help-to-understand-more-about-virtual-dom-4ci4 Websites That Help To Understand More About Virtual DomOne of the main principals of react is Virtual Dom Many react developers know about Virtual Dom how it works and how it helps But Beginner react developers maybe didn t got the idea about Virtual Dom So here are some links that might help you understand this easy concept CodeacademyReactjs orgProgramming with moshThank you for your time 2022-02-10 12:09:25
Apple AppleInsider - Frontpage News Caldigit Element Hub review: A compact Thunderbolt 4 hub for MacBook Pro https://appleinsider.com/articles/22/02/10/caldigit-element-hub-review-a-compact-thunderbolt-4-hub-for-macbook-pro?utm_medium=rss Caldigit Element Hub review A compact Thunderbolt hub for MacBook ProThe minimalist CalDigit Element Hub highlights the power of Thunderbolt featured on recent Apple devices The Thunderbolt CalDigit Element HubCalDigit has been a bit of a fan favorite around these parts with multiple AppleInsider staffers utilizing the popular TS Thunderbolt hub The Element Hub is entirely different more intended to work out of the home office Read more 2022-02-10 12:54:33
Apple AppleInsider - Frontpage News Apple removes 12 suppliers over 'conflict minerals' failures https://appleinsider.com/articles/22/02/10/apple-removes-12-suppliers-over-conflict-minerals-failures?utm_medium=rss Apple removes suppliers over x conflict minerals x failuresApple has reported that in it ceased working with smelters and refiners because of concerns about them mining in armed conflict areas Apple s audit aims to find out which suppliers are mining what are called conflict minerals As it reported in and also in Apple has informed the SEC that it has conducted a conflict minerals audit The company states that all of its existing smelters and refiners took part in the audit and that who did not were dropped from the supply chain Read more 2022-02-10 12:47:54
Apple AppleInsider - Frontpage News Microsoft's new app store pledge preserves its walled garden on Xbox https://appleinsider.com/articles/22/02/10/microsoft-announces-new-app-store-pledges-except-for-xbox?utm_medium=rss Microsoft x s new app store pledge preserves its walled garden on XboxMicrosoft has announced a series of pledges to do with App Store and fair dealing with developers but won t apply major ones to its Xbox store As governments around the world put pressure on Apple and Google over regulating their platforms Microsoft has announced what it calls a principled approach to app stores Specifically done to adapt ahead of regulation Microsoft says its principles address its growing role and responsibility in the market since its acquisition of Activision Blizzard Too much friction exists today between creators and gamers says Microsoft in a blog post app store policies and practices on mobile devices restrict what and how creators can offer games and what and how gamers can play them Read more 2022-02-10 12:58:11
Apple AppleInsider - Frontpage News Compared: iPhone 13 & iPhone 13 Pro versus Samsung Galaxy S22 https://appleinsider.com/articles/22/02/09/compared-iphone-13-lineup-versus-samsung-galaxy-s22-lineup?utm_medium=rss Compared iPhone amp iPhone Pro versus Samsung Galaxy SUntil Samsung s new S range of phones is shipping they can t readily be compared with Apple s iPhone models but the published specifications suggest the Android release has a lot going for it Samsung s Galaxy S and the iPhone ProSamsung has announced its new range of phones the Samsung S S Plus and S Ultra Although not even close to identical they are broadly aimed at the same kinds of users as Apple s iPhone iPhone Pro and iPhone Pro Max Read more 2022-02-10 12:57:31
海外TECH Engadget The Morning After: Samsung's Galaxy S22 Ultra is your new Galaxy Note https://www.engadget.com/the-morning-after-the-galaxy-s-22-ultra-is-your-new-galaxy-note-121558897.html?src=rss The Morning After Samsung x s Galaxy S Ultra is your new Galaxy NoteWhile I was very distracted this morning by Nintendo s barrage of game announcements the big story remains Samsung s new Galaxy S lineup Encompassing no less than three new phones and three new tablets it was a busy day for the biggest and most influential Android phone maker While the giant Tab S Ultra is literally the biggest announcement a inch OLED tablet built for creating and viewing the most important might be the Galaxy S Ultra ーdespite the name to most people this is really the next gen Galaxy Note EngadgetMy colleague Cherlynn Low has written about how the Note s legacy will live on in any device that works with a Samsung stylus but it s a much needed consolidation of the myriad flagship devices the company often launches at a speedy clip Last year sidestepping Samsung s cheaper phones like the A series it revealed the Galaxy S S and S Ultra in January Then in August the company marched out its latest foldable devices the Galaxy Z Fold and the Galaxy Z Flip Not to mention the S Fan Edition that popped up just a few weeks ago… Phew There was no Galaxy Note that year presumably because Samsung needed to figure out where it would belong The S Ultra with lots of camera sensors a huge beautiful screen and space to holster an S Pen stylus now has enough unique features to differentiate itself from the more standard and cheaper S and S Now I need to figure out how to stop calling it a Note ーMat SmithThe biggest stories you might have missedHere s everything Samsung announced at its Galaxy S Unpacked eventSamsung s Galaxy S Ultra vs the competition Bring on the S PenSony s Sophy racing AI beats Gran Turismo s top talent Nintendo Switch Sports brings bowling tennis and more on April th EngadgetMicrosoft promises to keep Call of Duty on PlayStationTwitter parts ways with two factor provider following claims of secret surveillance Nintendo Switch Online adds EarthBound Beginnings and EarthBound Mario Kart Deluxe is getting courses from older gamesCult classic JRPG Chrono Cross is getting a remaster for consoles and PCThe Galaxy S and S have improved cameras and slightly smaller screensBoth devices launch on February th The inch Galaxy S and inch S look very similar to the S family they replace but they include some notable camera upgrades including a megapixel main rear camera with a sensor percent larger than in the MP shooter from their predecessors There are some new software based camera tricks including Auto Framing to keep up to people in focus Portrait mode photos should look more natural thanks to an AI based stereo depth map Prices start at for a Galaxy S with GB of non expandable storage and for the bigger S Still not sure We ve already written up some first impressions right here and you can expect our full review soon Continue reading Samsung s Galaxy S Ultra has a built in S Pen and lots of camerasIt s the Galaxy Note in all but name Compared to its S siblings the Ultra model has a flatter design and built in storage for Samsung s S Pen stylus which itself features improved responsiveness It also comes with a MP camera with an f aperture lens The phone includes a MP ultra wide camera and two MP telephoto cameras Pre orders for the device open today with prices beginning at for the base model with GB of RAM and GB of internal storage Check out our early thoughts here Continue reading Samsung reveals the Galaxy Tab S UltraAndroid on a very big screen Samsung also unveiled the Galaxy Tab S series which includes the Tab S S and the Tab S Ultra It s the first time Samsung is making a tablet with the “Ultra name that branding is normally reserved for its S series phones but the S Ultra has some high end specs to match According to Samsung it features the “world s only inch Super AMOLED display on an Android in as well as “our smoothest writing experience yet courtesy of an upgraded S Pen Pricing across the family starts at for the Tab S the S at and the Ultra at They are all impressively slim Continue reading Watch Samsung s bizarre Bridgerton esque Galaxy S revealBridgertown I can t explain what Samsung s original idea was There s a vague dig at Apple I think as an old Mr Mackintosh pitches a dowdy raincoat before a younger handsome man appears to reveal…oil paintings of Samsung s newest phone The matriarch he s trying to impress demands her servants carry the paintings around in a circle by candlelight creating possibly a sort of zoetrope effect I m not sure You won t be sure Continue reading SpaceX loses Starlink satellites to a geomagnetic stormThey ll burn up as they re enter the atmosphere Almost all of the Starlink internet satellites a SpaceX Falcon rocket carried beyond the atmosphere on February rd won t reach their intended orbit SpaceX has revealed a geomagnetic storm a day after liftoff had a severe impact on the satellites and up to of them will re enter or have already entered Earth s atmosphere The deorbiting satellites pose no collision risk SpaceX said and will completely burn up as they re enter the atmosphere leaving no orbital debris Continue reading You may never have to charge Garmin s newest smartwatchYou ll just need to spend a few hours in bright sunlight every day instead GarminGarmin s new Instinct Solar watch will apparently be able to run continuously on smartwatch mode i e with features like heart rate monitoring sleep tracking activity tracking and health monitoring turned on with no need to recharge ーso long as you get enough hours in the sun Garmin says the device needs to be outside in lux conditions for an average of three hours a day to maintain the quot unlimited quot battery life Continue reading Apple source code references realityOS for potential VR AR headsetsThe headsets are reported to arrive in or The operating system powering Apple s rumored virtual or augmented reality headset may be called realityOS MacRumors has reported The term was spotted by multiple sources in recent GitHub open source code and App Store upload logs quot What is Apple s realityOS doing in the App Store upload logs quot tweeted iOS developer Rens Verhoeven If the references are real they could suggest that developers are getting or will be getting access to the OS As another developer Steve Troughton Smith warned however they quot could just be a remnant of somebody s pull request from a fake account quot too Continue reading 2022-02-10 12:15:58
金融 RSS FILE - 日本証券業協会 新規公開に際して行う株券の個人顧客への配分状況 https://www.jsda.or.jp/shiryoshitsu/toukei/shinkikoukai/index.html 新規公開 2022-02-10 13:00:00
ニュース BBC News - Home Ukraine-Russia crisis: Stakes are very high, Boris Johnson says https://www.bbc.co.uk/news/uk-60326142?at_medium=RSS&at_campaign=KARANGA diplomacy 2022-02-10 12:24:14
ニュース BBC News - Home Prince Charles tests positive for Covid, Clarence House says https://www.bbc.co.uk/news/uk-60334842?at_medium=RSS&at_campaign=KARANGA clarence 2022-02-10 12:49:48
ニュース BBC News - Home Johnson broke law over No 10 parties, says ex-PM Sir John Major https://www.bbc.co.uk/news/uk-politics-60331189?at_medium=RSS&at_campaign=KARANGA johnson 2022-02-10 12:48:08
ニュース BBC News - Home Met Police: Dame Cressida Dick says she has no intention of quitting https://www.bbc.co.uk/news/uk-england-london-60319838?at_medium=RSS&at_campaign=KARANGA report 2022-02-10 12:39:39
ニュース BBC News - Home Russian gallery security guard accused of drawing eyes on painting https://www.bbc.co.uk/news/world-europe-60330758?at_medium=RSS&at_campaign=KARANGA guard 2022-02-10 12:22:22
ニュース BBC News - Home Tottenham ask fans to 'move on' from using Y-word after review https://www.bbc.co.uk/sport/football/60330719?at_medium=RSS&at_campaign=KARANGA tottenham 2022-02-10 12:20:41
ニュース BBC News - Home Scotland make five changes for Wales match https://www.bbc.co.uk/sport/rugby-union/60334673?at_medium=RSS&at_campaign=KARANGA front 2022-02-10 12:26:06
ニュース BBC News - Home Flanker Morgan to make Wales debut against Scotland https://www.bbc.co.uk/sport/rugby-union/60325490?at_medium=RSS&at_campaign=KARANGA cardiff 2022-02-10 12:30:14
ニュース BBC News - Home Winter Olympics: Chloe Kim wins snowboard halfpipe gold to retain title https://www.bbc.co.uk/sport/winter-olympics/60328694?at_medium=RSS&at_campaign=KARANGA olympic 2022-02-10 12:50:07
北海道 北海道新聞 飲酒ひき逃げ容疑 20歳の男を逮捕 札幌北署 https://www.hokkaido-np.co.jp/article/644450/ 道交法違反 2022-02-10 21:11:00
北海道 北海道新聞 緊急時のオンライン審議に前向き意見 衆院憲法審 https://www.hokkaido-np.co.jp/article/644448/ 憲法審査会 2022-02-10 21:09:00
北海道 北海道新聞 北京冬季五輪、9人がコロナ陽性 9日の検査で、大会組織委発表 https://www.hokkaido-np.co.jp/article/644447/ 北京冬季五輪 2022-02-10 21:08:00
北海道 北海道新聞 春目指し面接、作文臨む 道南でも公立高推薦入試 https://www.hokkaido-np.co.jp/article/644445/ 高校 2022-02-10 21:06:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)