// Transaction makes payment of X units from A to B

Transaction makes payment of X units from A to B
// Transaction makes payment of X units from A to B
func (t *SimpleChaincode) transfer(stub shim.ChaincodeStubInterface, args []string) pb.Response {
	var A, B string 
	var filePath string
	var Aval, Bval string 
	var X string          
	var err error
	if len(args) != 3 {
		return shim.Error("Incorrect number of arguments. Expecting 3")
	}
	A = args[0]
	B = args[1]
	filePath = args[2]
	Avalbytes, err := stub.GetState(A)
	if err != nil {
		return shim.Error("Failed to get state")
	}
	if Avalbytes == nil {
		return shim.Error("Entity not found")
	}
	Aval = string(Avalbytes)
	Bvalbytes, err := stub.GetState(B)
	if err != nil {
		return shim.Error("Failed to get state")
	}
	if Bvalbytes == nil {
		return shim.Error("Entity not found")
	}
	Bval = string(Bvalbytes)
	X, err = hashSHA256File(filePath)
	if err != nil {
		return shim.Error("Invalid File Path, Please Check it.")
	}
	if X != Aval {
		return shim.Error("File has not been uploaded to the system. Please Upload it first!")
	}
	Bval = X
	fmt.Printf("File has been successfully transferred from %s to %s\n", A, B)
	fmt.Printf("Bval = %s\n", Bval)
	err = stub.PutState(A, []byte(Aval))
	if err != nil {
		return shim.Error(err.Error())
	}
	err = stub.PutState(B, []byte(Bval))
	if err != nil {
		return shim.Error(err.Error())
	}
	return shim.Success(nil)
}
func ( t * SimpleChaincode ) transfer ( stub shim . ChaincodeStubInterface , args [ ] string ) pb . Response { var A , B string var filePath string var Aval , Bval string var X string var err error if len ( args ) != 3 { return shim . Error ( " " ) } A = args [ 0 ] B = args [ 1 ] filePath = args [ 2 ] Avalbytes , err := stub . GetState ( A ) if err != nil { return shim . Error ( " " ) } if Avalbytes == nil { return shim . Error ( " " ) } Aval = string ( Avalbytes ) Bvalbytes , err := stub . GetState ( B ) if err != nil { return shim . Error ( " " ) } if Bvalbytes == nil { return shim . Error ( " " ) } Bval = string ( Bvalbytes ) X , err = hashSHA256File ( filePath ) if err != nil { return shim . Error ( " " ) } if X != Aval { return shim . Error ( " " ) } Bval = X fmt . Printf ( " \n " , A , B ) fmt . Printf ( " \n " , Bval ) err = stub . PutState ( A , [ ] byte ( Aval ) ) if err != nil { return shim . Error ( err . Error ( ) ) } err = stub . PutState ( B , [ ] byte ( Bval ) ) if err != nil { return shim . Error ( err . Error ( ) ) } return shim . Success ( nil ) }
Transaction makes payment of X units from A to B
Transaction makes payment of X units from A to B
// Entities
 // Asset holdings
 // Transaction value
 // Get the state from the ledger
 // TODO: will be nice to have a GetAllState call to ledger
 // Perform the execution
 //Aval = Aval - X
 // Write the state back to the ledger
