contracts
directory. In the directory, create two files: Ownable.sol
and DocStamp.sol
.
issueCertificate()
— generates a certificate by calculating a hash of the student name and details.
records[certificate] = msg.sender
.owningAuthority()
— returns the address of issuer/authority.
verifyCertificate()
— calculates a hash of the student name and details, and checks if the contract is on the blockchain.
2_deploy_contracts.js
in the migrations
directory.
build/contracts
directory in the .json
format. If the contract does not compile, check the compiler version in your truffle-config.js
file and ensure that your compiler version matches the pragma solidity version of the contract.
truffle-config.js
.
instance
to see the contract object ABI, bytecode, and methods.
owner
to see the account that deployed the contract and owns the contract.
result.logs
to view the full certificate details.
result.logs
.See also Processing transaction results.record
value in the output. This is the hash of the certificate values: name and details. You will need this hash to create the contract test later in this tutorial.
result.logs
.verify
will now print true
if there is a match, and false
if there is no match.
test
directory.
test.js
file:
result.logs
.Passing
.
HDWalletProvider
.
HDWalletProvider is Truffle’s separate npm package used to sign transactions.
Run:
truffle-config.js
to add:
sepolia
— any network name that you will pass to the truffle migrate --network
command.HDWalletProvider
— Truffle’s custom provider to sign transactionsmnemonic
— your mnemonic that generates your accounts. You can also generate a mnemonic online with Mnemonic Code Converter. Make sure you generate a 15-word mnemonic.network_id
— the Ethereum Sepolia testnet network ID: 5
.2_deploy_contracts.js
and deploy the contract to the Ethereum Sepolia testnet as specified in truffle-config.js
.