How to add an attribute to a paragraph block

I think the Transform.setNodeMarkup() method is how, but I don’t know how to get the position parameter from the current selection.

let { $from } = state.selection,  index = $from.index();
let {attrs}  = $from.parent;
tr.setNodeMarkup(position???, null, {...attrs, someValue });

I think you can use like this way dispatch(tr.setNodeMarkup($from.before(), undefined, { ...attrs, someValue }))

Thanks, that worked!