mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
27 lines
635 B
Go
27 lines
635 B
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hyperledger/fabric-gateway/pkg/client"
|
|
)
|
|
|
|
// cmdCreate creates a new asset on the ledger.
|
|
// Arguments: <assetId> <ownerName> <color>
|
|
func cmdCreate(gw *client.Gateway, args []string) error {
|
|
if len(args) < 3 {
|
|
return fmt.Errorf("arguments: <assetId> <ownerName> <color>")
|
|
}
|
|
|
|
network := gw.GetNetwork(channelName())
|
|
contract := network.GetContract(chaincodeName())
|
|
|
|
smartContract := NewAssetTransfer(contract)
|
|
return smartContract.CreateAsset(Asset{
|
|
ID: args[0],
|
|
Owner: args[1],
|
|
Color: args[2],
|
|
Size: 1,
|
|
AppraisedValue: 1,
|
|
})
|
|
}
|