1 2 3 | func (t *SampleChaincode) Init(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) { return nil, nil } |
1 2 3 | func (t *SampleChaincode) Query(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) { return nil, nil } |
1 2 3 | func (t *SampleChaincode) Invoke(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) { return nil, nil } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | //custom data models type PersonalInfo struct { Firstname string `json:"firstname"` Lastname string `json:"lastname"` DOB string `json:"DOB"` Email string `json:"email"` Mobile string `json:"mobile"` } type FinancialInfo struct { MonthlySalary int `json:"monthlySalary"` MonthlyRent int `json:"monthlyRent"` OtherExpenditure int `json:"otherExpenditure"` MonthlyLoanPayment int `json:"monthlyLoanPayment"` } type LoanApplication struct { ID string `json:"id"` PropertyId string `json:"propertyId"` LandId string `json:"landId"` PermitId string `json:"permitId"` BuyerId string `json:"buyerId"` SalesContractId string `json:"salesContractId"` PersonalInfo PersonalInfo `json:"personalInfo"` FinancialInfo FinancialInfo `json:"financialInfo"` Status string `json:"status"` RequestedAmount int `json:"requestedAmount"` FairMarketValue int `json:"fairMarketValue"` ApprovedAmount int `json:"approvedAmount"` ReviewerId string `json:"reviewerId"` LastModifiedDate string `json:"lastModifiedDate"` } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | func CreateLoanApplication(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) { fmt.Println("Entering CreateLoanApplication") if len(args) < 2 { fmt.Println("Invalid number of args") return nil, errors.New("Expected at least two arguments for loan application creation") } var loanApplicationId = args[0] var loanApplicationInput = args[1] err := stub.PutState(loanApplicationId, []byte(loanApplicationInput)) if err != nil { fmt.Println("Could not save loan application to ledger", err) return nil, err } fmt.Println("Successfully saved loan application") return nil, nil } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |