Research Article

Based on Consortium Blockchain to Design a Credit Verifiable Cross University Course Learning System

Algorithm 1

Chaincode used for initialization.
(1)type Chaincode struct {
(2)}
(3)type Teacher struct {
(4) Name string ‘json:”name”’
(5) University string ‘json:”university”’
(6) Course string ‘json:”course”’
(7)}
(8)type Student struct {
(9) Name string ‘json:”name”’
(10) University string ‘json:”university”’
(11) Hash string ‘json:”hash”’
(12) Grade int ‘json:”grade”’
(13) Credit int ‘json:”credit”’
(14)}
(15)func (t Chaincode) Init(stub shim.ChaincodeStubInterface) peer.Response {
(16) return shim.Success(nil)
(17)}
(18)func (t Chaincode) Invoke(stub shim.ChaincodeStubInterface) peer.Response {
(19) function, args: = stub.GetFunctionAndParameters()
(20) if function = = “CheckCourse” {
(21)  return t.CheckCourse(stub, args)
(22)} else if function = = “LearnCourse” {
(23)  return t.LearnCourse(stub, args)
(24)} else if function = = “WorkUpload” {
(25)  return t.WorkUpload(stub, args)
(26)} else if function = = “AddGrade” {
(27)  return t.AddGrade(stub, args)
(28)} else if function = = “CheckStudent” {
(29)  return t.CheckStudent(stub, args)
(30)} else if function = = “AwardCredit” {
(31)  return t.AwardCredit(stub, args)
(32)}
(33)return shim.Error(“Invalid Smart Contract function name. “)
(34)}