Share
Sign In
공부 내용
fabric application
Y
yeji Kim
👍
about asset transfer
구성 요소
샘플 app
smart contract
샘플 app 준비하기
npm install → 종속성 설치, 앱 빌드
1. gateway에 대한 gRPC 연결 설정
2. gateway 연결 생성
요구사항
fabric gateway에 대한 gRPC 연결
네트워크와 거래할 때 사용되는 client ID
디지털 서명
3. 호출할 계약에 액세스
gateway.getNetwork, network.getContract
4. 샘플 자산으로 원장 채우기
submitTranscation은 fabric gateway를 통해 다음을 수행
1.
거래 제안 승인
2.
승인된 거래를 주문 서비스에 제출
3.
트랜젝션이 커밋되고 원장 상태가 업데이트될 때까지 대기
샘플 앱에 initLedger 호출. contract.submitTransaction
5. 트랜잭션 함수를 호출하여 자산 읽고 쓰기.
const resultBytes = await contract.evaluateTransaction('GetAllAssets'); const resultJson = utf8Decoder.decode(resultBytes); const result = JSON.parse(resultJson); console.log('*** Result:', result);
새 자산 만들기
const assetId = `asset${Date.now()}`; await contract.submitTransaction( 'CreateAsset', assetId, 'yellow', '5', 'Tom', '1300', );
자산 업데이트
const commit = await contract.submitAsync('TransferAsset', { arguments: [assetId, 'Saptha'], }); const oldOwner = utf8Decoder.decode(commit.getResult()); console.log(`*** Successfully submitted transaction to transfer ownership from ${oldOwner} to Saptha`); console.log('*** Waiting for transaction commit'); const status = await commit.getStatus(); if (!status.successful) { throw new Error(`Transaction ${status.transactionId} failed to commit with status code ${status.code}`); } console.log('*** Transaction committed successfully');
업데이트된 자산 쿼리
const resultBytes = await contract.evaluateTransaction('ReadAsset', assetId); const resultJson = utf8Decoder.decode(resultBytes); const result = JSON.parse(resultJson); console.log('*** Result:', result);
트랜잭션 오류 처리
try { await contract.submitTransaction( 'UpdateAsset', 'asset70', 'blue', '5', 'Tomoko', '300', ); console.log('******** FAILED to return an error'); } catch (error) { console.log('*** Successfully caught the error: \n', error); }
Subscribe to '아무튼-작업일지'
Welcome to '아무튼-작업일지'!
By subscribing to my site, you'll be the first to receive notifications and emails about the latest updates, including new posts.
Join SlashPage and subscribe to '아무튼-작업일지'!
Subscribe
👍
Other posts in '공부 내용'See all
yeji Kim
궁금한 것 보증 정책 : 주어진 스마트 컨트렉트에 의해 생성된 거래에 서명해야 하는 블록체인 네트워크의 조직 for 해당 거래가 유효하다고 선언 → 유효하다는 선언은 어떻게 하지? 유효 여부에 관계없이 모든 거래는 블록체인에 기록되지만 유효한 거래만 world state에 기여 ex 자동차 이체 거래 t3 : ORG1과 ORG2 사이의 자동차 환승에 대한
궁금한 것 보증 정책 : 주어진 스마트 컨트렉트에 의해 생성된 거래에 서명해야 하는 블록체인 네트워크의 조직 for 해당 거래가 유효하다고 선언 → 유효하다는 선언은 어떻게 하지? 유효 여부에 관계없이 모든 거래는 블록체인에 기록되지만 유효한 거래만 world state에 기여 ex 자동차 이체 거래 t3 : ORG1과 ORG2 사이의 자동차 환승에 대한 트랜잭션 입력 : {CAR1, ORG1, ORG2} 출력 : {CAR1.owner=ORG1, CAR1.owner=ORG2} => ORG1에서 ORG2로 소유자가 변경되었음을 나타내는 방법 애플리케이션의 조직 ORG1에서 입력이 서명 보증 정책 ORG1 및 ORG2로 식별된 두 조직에서 출력이 서명 서명은 개인 키를 사용하여 생성 네트워크의 모든 노드가 트랜잭션에 대해 동의, 네트워크의 모든 사람이 확인 가능 트랜잭션 : 두 단계의 검증 보증 정책에 따라 충분한 조직에서 서명했는지 확인 world state의 현재 값이 보증 피어 노드에 의해 서명되었을 때 트랜잭션의 읽기 세트와 일치하는지 확인 즉, 중간에 업데이트가 없었는지 확인 트랜잭션이 이 테스트를 모두 통과하면 유효한 것으로 표시됩니다. 조직이 서로 다른 상대방과 작업 트래픽을 분리하는 데 도움이 될 만큼 충분히 독립적 필요할 때 독립적인 활동을 조정할 수 있도록 충분히 통합됨. 대부분의 시나리오에서 위에서 설명한 체인코드 수명 주기 메커니즘을 사용하는 대신 체인코드에 초기화 논리를 포함 권고
yeji Kim
DB 변경 생길 때마다 알림 주기 - MySQL trigger, flutter cron
GPT To receive notifications when a change occurs in the user's schedule value in the database, you can implement several approaches depending on your specific needs and the technologies you're comfortable with. Here’s a high-level overview of the options: 1. Polling (Active Checking) How it works: You can create a script that periodically checks the database for changes. If a change is detected, the script sends a notification. Steps: Set up a CRON job (or Windows Task Scheduler if on Windows) that runs a script every X minutes. The script queries the database for changes in the user's schedule value. If a change is detected, send a notification (e.g., via email, SMS, or push notification). Pros: Easy to implement. Cons: Not real-time, may introduce unnecessary load on the server if the polling frequency is too high. 2. Database Triggers + Notification System How it works: Use a database trigger to detect changes and invoke a notification system. Steps: Create a Trigger: Set up a trigger in your MySQL database (if you're using MySQL with XAMPP) that activates when a change occurs in the user's schedule table. Trigger Action: The trigger could insert a record into a separate "notifications" table or call an external script to send a notification. Notification System: Use a script or service (such as an email or SMS API) to send notifications when new records are added to the "notifications" table. Pros: Real-time notifications, less overhead than polling. Cons: More complex setup, requires database-level modifications. Example of a MySQL trigger: 3. WebSocket or Server-Sent Events (SSE)
yeji Kim
피그마
frame 해상도 - 점유도 커뮤니티 ui KIT - duplicate 버튼생성하기 1-3, 프로토타이핑, text styling, auto layouthttps://www.youtube.com/watch?v=E4NfxpV9hpE 미드저니