[BlockChain] Metamask
학습목표
- Metamask가 무엇인지 간단히 설명할 수 있다.
- Metamask로 현재 잔액확인을 할 수 있다.
- Metamask로 다른 지갑에 트랜잭션을 전송할 수 있다.
- Metamask로 transaction receipt를 조회할 수 있다.
1. Metamask
- Web3에서사용자 상호 작용과 경험을 가능하게 하는 도구
- metamask 참고문서
2. Methods 기본
- ethereum.selectedAddress : 현재 연결된 지갑 주소 반환
- ethereum.isConnected() : 연결여부 확인
- ethereum.request({object}) : RPC 요청
3. request methods
- RPC API Doc
- RPC API Playground Doc
-
양식
// POST method ethereum.request({ jsonrpc: "2.0", method: {함수명}, params: [인수] })
3.1 잔액 확인
- eth_getBalance
-
양식
// POST method ethereum.request({ jsonrpc: "2.0", method: "eth_getBalance", params: [지갑주소, "latest"] })
3.2 화폐 전송
- eth_sendTransaction
-
양식
// POST method ethereum.request({ jsonrpc: "2.0", method: "eth_sendTransaction", params: [{ "from": 전송자, "to": 수신자, "gas": "0x76c0", // 30400 "gasPrice": "0x9184e72a000", // 10000000000000 "value": 금액, // 2441406250 "data": 16진수 문자열 }] })
3.3 영수증 확인
- eth_getTransactionReceipt
-
양식
// POST method ethereum.request({ { "jsonrpc": "2.0", "method": "eth_getTransactionReceipt", "params": ["0xfc454ccdeaeb0d4496cef74a10d6682dc475374969f8a702266cf0321de9b526"], "id": 0 } })
4. Etherscan
- 이더리움 블록체인에서 일어나고있는 모든 활동과 정보를 쉽게 검색할 수 있는 사이트
- 이더리움의 블록 생성, 트랜잭션, 지갑 정보, 이더리움 기반 토큰등등 조회 가능
-