How to add legend and scale to the map

Dear sir/madam,
I recently started using the GMT for making maps. I don’t know how to add legend, I tried but I am not able to add it. please help me by providing the information regrading how to add legend for the below code.

@echo off
REM Date: 2024-03-07T21:56:07
REM User: USER
REM Purpose: Purpose of this script
REM Set a unique session name:
set GMT_SESSION_NAME=10976
set gps=“GNSS.dat”
set output=“demo”
gmt makecpt -Cdem2 -T-100/6000/100 -Z -D > topo.cpt

gmt begin %output% png
gmt basemap -JM20c -R75/90/24/33 -Ba1f0.5
gmt grdimage @earth_relief_15s -I+nt.3 -Ctopo.cpt
gmt velo %gps% -W**0.1p,black -Gblack -Se0.05/0.65/12 -A10p+ea+n10+gblack
gmt end

Thank you sir/madam in advance.

Two ways :
Either automatically with -l at the instruction of interest

gmt plot file.txt [...] -l"A plot"

or manually with legend module (see documentation)