Пример #1
0
// Init intializes the chaincode by reading the transaction attributes and storing
// the attrbute values in the state
func (t *SimpleChaincode) Init(stub *shim.ChaincodeStub, function string, args []string) ([]byte, error) {
	attributes, err := stub.CertAttributes()
	if err != nil {
		return nil, err
	}

	for _, att := range attributes {
		fmt.Println("Writting attribute " + att)
		var attVal []byte
		attVal, err = stub.ReadCertAttribute(att)
		if err != nil {
			return nil, err
		}
		err = stub.PutState(att, attVal)
		if err != nil {
			return nil, err
		}
	}

	return nil, nil
}