Giter VIP home page Giter VIP logo

biss-blockchain's Introduction

BISS-Blockchain

Smart Contract used in BISS(Updated after Hackathon)

BISS 시스템에서 사용되는 스마트 컨트랙트입니다.

목차

데이터 전송 및 수신

  1. 디바이스는 자신의 Klaytn 지갑 주소를 sender로 sendData()를 호출하고, 돌아오는 receipt의 txHash를 서버로 보냅니다.
  2. 서버는 txHash의 트랜잭션을 조회하고, 전송된 데이터를 구합니다.

sendData

Biss.methods.saveData('ASDF').send({from: '0x81733c8d5ee8c76241c33537c072cd05d71b3d21'})

인수

이름 타입 설명
_message string 전송할 메세지

txHash에서 데이터 꺼내기

단순히 이런 기능만 필요한 서버 및 END 디바이스는 본 저장소를 클론할 필요가 없습니다.

  1. https://apiscope.klaytn.com/api/transaction/{txHash}로 GET 리퀘스트를 보낸 뒤 ["result"]["input"]의 hex 데이터를 ASCII로 변환하면 됩니다. 아래와 같이 caver-jshexToAscii를 이용하거나, 다른 방법을 이용할 수 있습니다.
var Caver = require('caver-js');
var caver = new Caver();
console.log(caver.utils.hexToAscii(hex));
  1. ASDF가 데이터라고 하면, 결과는 대충 아래 같을 거예요.
ÄjÒ asdf

앞에 있는 4개 문자(ÄjÒ )를 제거해주고 이용하면 끝~! 물론, hex 데이터를 ASCII로 바꾸는 과정에서 없애도 좋겠지요!

펌웨어 업데이트 관련

saveKey

Biss.methods.saveKey('1', 'I9L1bUJyY5289a0eec94a441e9624d5108c4f8c084').send({from: '0x81733c8d5ee8c76241c33537c072cd05d71b3d21'})

인수

이름 타입 설명
_fileID string 파일 ID
_key string 파일 key

saveHash

Biss.methods.saveHash(file_id, hash).send({from: '0x81733c8d5ee8c76241c33537c072cd05d71b3d21'})

인수

이름 타입 설명
_fileID string 파일 ID
_hash string 파일 hash

verifyHash

Biss.methods.verifyHash('1', '931d9212c4071dc694a9d73e6533c7d4').call()

인수

이름 타입 설명
_fileID string 파일 ID
_hash string 파일 hash

반환값

타입 설명
bool 블록체인에 저장된 _fileID의 해시와 _hash가 같은 경우 true

biss-blockchain's People

Contributors

junhoyeo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.