pragma cashscript ^0.6.3;
contract FT(bytes20 owner) {
// Warning: This method 'reclaim' should only be used in testing.
// Backdoor to reclaim funds,
function reclaim(pubkey pk, sig s) {
require(checkSig(s, pk));
}
function createToken(
pubkey pk,
sig s,
bytes20 recipientPkh,
bytes lokadId,
bytes tokenType,
string actionType,
string symbol,
string name,
string documentURI,
string documentHash,
bytes decimals,
bytes baton,
bytes initialQuantity,
int minerFee,
//string memoText
) {
require(hash160(pk) == owner);
require(checkSig(s, pk));
int dust = 546;
bytes token = new OutputNullData([
lokadId,
tokenType,
bytes(actionType),
bytes(symbol),
bytes(name),
bytes(documentURI),
bytes(documentHash),
decimals,
baton,
initialQuantity
]);
// bytes memo = new OutputNullData([
// 0x6d02,
// bytes(memoText)
// ]);
int changeAmount = int(bytes(tx.value)) - minerFee - dust;
if (changeAmount >= dust) {
bytes34 recipient = new OutputP2PKH(bytes8(dust), recipientPkh);
// Get the change back to the contract i.e Pay to Script Hash which is the current contract.
bytes32 change = new OutputP2SH(bytes8(changeAmount), hash160(tx.bytecode));
//require(hash256(token + recipient + change + memo) == tx.hashOutputs);
require(hash256(token + recipient + change) == tx.hashOutputs);
} else {
require(hash256(token) == tx.hashOutputs);
}
}
}// Check the tokens/genesis.tsx
// import { hexToBin } from '@bitauth/libauth'
const lokadId = '0x534c5000'
...
const lokadIdBin = hexToBin(lokadId.substring(2))
...
const tx = await contract.functions
.createToken(
userPk,
new SignatureTemplate(user),
userPkh,
lokadIdBin,
...
minerFee,
)
.withOpReturn([
lokadId,
...
initialQuantity
])
.to(slpRecipient, dust)
.to(contract.address, change)
// .withOpReturn([
// '0x6d02',
// strr,
// ])
.withHardcodedFee(minerFee)
//.build()
.send();pragma cashscript ^0.6.0;
contract NFT(bytes20 owner) {
// Warning: This method 'reclaim' should only be used in testing.
// Backdoor to reclaim funds,
function reclaim(pubkey pk, sig s) {
require(hash160(pk) == owner);
require(checkSig(s, pk));
}
// Warning: This method 'createNFTChild' should only be used in testing.
// Backdoor to reclaim funds,
function createNFTChild(pubkey pk, sig s) {
require(hash160(pk) == owner);
require(checkSig(s, pk));
}
function createNFTGroup(
pubkey pk,
sig s,
bytes20 recipientPkh,
string actionType,
string symbol,
string name,
string documentURI,
string documentHash,
int minerFee,
) {
require(hash160(pk) == owner);
require(checkSig(s, pk));
bytes announcement = new OutputNullData([
0x534c5000,
0x81,
bytes(actionType),
bytes(symbol),
bytes(name),
bytes(documentURI),
bytes(documentHash),
0x00,
0xff, // Trick: Keep this number above the number of transactions you would expect.
0x0000000000001388
]);
// Calculate leftover money after fee (1000 sats)
// Add change output if the remainder can be used
// otherwise donate the remainder to the miner
// int minerFee = 1000;
int dust = 546;
int changeAmount = int(bytes(tx.value)) - dust - minerFee;
// require(changeAmount > dust);
if (changeAmount >= minerFee) {
bytes34 recipient = new OutputP2PKH(bytes8(dust), recipientPkh);
bytes32 change = new OutputP2SH(bytes8(changeAmount), hash160(tx.bytecode));
require(hash256(announcement + recipient + change) == tx.hashOutputs);
} else {
require(hash256(announcement) == tx.hashOutputs);
}
}
}All Protos used by Cashkit. ⚙️
#!/bin/bash
export PATH="$PATH:$(go env GOPATH)/bin"
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative bchrpc/bchrpc.proto
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative kitrpc/kitrpc.protousername=<your-rpc-user-name>
password=<your-rpc-password>
bchdusername=<your-rpc-user-name>
bchdpassword=<your-rpc-password>
rpccert=./rpc.crt # See certificates.md
rpckey=./rpc.key # See certificates.mdrpcuser=<your-rpc-user-name>
rpcpass=<your-rpc-password>
rpccert=./rpc.crt # See certificates.md[Application Options]
rpcuser=<your-rpc-user-name>
rpcpass=<your-rpc-password>
rpclisten=:8334
rpccert=./rpc.crt
rpckey=./rpc.key
grpclisten=[::]:8335
prunedepth=300
txindex=1
addrindex=1
debuglevel=info#!/bin/bash
# Changes these CN's to match your hosts in your environment if needed.
SERVER_CN=localhost
# Step 1: Generate Certificate Authority + Trust Certificate (ca.crt)
openssl genrsa -passout pass:1111 -des3 -out ca.key 4096
openssl req -passin pass:1111 -new -x509 -days 3650 -key ca.key -out ca.crt -subj "/CN=${SERVER_CN}"
# Step 2: Generate the Server Private Key (server.key)
openssl genrsa -passout pass:1111 -des3 -out server.key 4096
# Step 3: Get a certificate signing request from the CA (server.csr)
openssl req -passin pass:1111 -new -key server.key -out server.csr -subj "/CN=${SERVER_CN}" -config certs.cnf
# Step 4: Sign the certificate with the CA we created (it's called self signing) - server.crt
openssl x509 -req -passin pass:1111 -days 3650 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt -extensions req_ext -extfile certs.cnf
# Step 5: Convert the server certificate to .pem format (server.pem) - usable by gRPC
openssl pkcs8 -topk8 -nocrypt -passin pass:1111 -in server.key -out server.pem
# Addon: Generating unencrypted key for bchd server
# openssl rsa -in server.pem -out key.unencrypted.pem -passin pass:1111[ req ]
default_bits = 4096
distinguished_name = dn
req_extensions = req_ext
prompt = no
[ dn ]
CN = localhost
[ req_ext ]
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
DNS.2 = 127.0.0.1



